Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build-std): make Resolve align to what to build #14938

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(build-std): resolve too less deps
This failed because since 125e873
[`std_resolve`][1] only includes `sysroot` as primary package.
When any custom Cargo feature is provided via `-Zbuild-std-feature`,
the default feature set `panic-unwind` would be gone, so no
`panic_unwind` crate presents in `std_resolve`.

When then calling [`std_resolve.query`][2] with the default set of
crates from [`std_crates`][3], which automatically includes
`panic_unwind` when `std` presents, it'll result in spec not found
because `panic_unwind` was not in `std_resolve` anyway.

[1]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L96
[2]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L158
[3]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L156

See #14935
  • Loading branch information
weihanglo committed Dec 18, 2024
commit f004691aa41449fa06b764683385558edee51428
27 changes: 27 additions & 0 deletions tests/build-std/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,30 @@ fn test_proc_macro() {
"#]])
.run();
}

#[cargo_test(build_std_real)]
fn test_panic_abort() {
// See rust-lang/cargo#14935
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
edition = "2021"
"#,
)
.file("src/lib.rs", "#![no_std]")
.build();

p.cargo("check")
.build_std_arg("std,panic_abort")
.env("RUSTFLAGS", "-C panic=abort")
.arg("-Zbuild-std-features=panic_immediate_abort")
.with_status(101)
.with_stderr_data(str![[r#"
[ERROR] package ID specification `panic_unwind` did not match any packages

"#]])
.run();
}