Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 0 additions & 5 deletions src/cargo/core/compiler/custom_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,6 @@ fn build_work(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResul
// sorts of variables need to be discovered at that time.
let lib_deps = dependencies
.iter()
// We allow std dependencies to propagate metadata between other std dependencies but
// not to non-std crates. Non-std crates can propagate metadata to other non-std crates.
// We enforce a boundary between std and non-std crates. This may be lifted in the
// future but for now we are being conservative.
.filter(|dep| dep.unit.is_std == unit.is_std)
.filter_map(|dep| {
if dep.unit.mode.is_run_custom_build() {
let dep_metadata = build_runner.get_run_build_script_metadata(&dep.unit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ name = "compiler_builtins"
version = "0.1.0"
authors = ["Alex Crichton <[email protected]>"]
edition = "2018"
links = "compiler-rt"
3 changes: 3 additions & 0 deletions tests/testsuite/mock-std/library/compiler_builtins/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("cargo::metadata=compiler-rt=foo");
}
24 changes: 24 additions & 0 deletions tests/testsuite/standard_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ fn build_std_with_no_arg_for_core_only_target() {
[COMPILING] compiler_builtins v0.1.0 ([..]/library/compiler_builtins)
[COMPILING] core v0.1.0 ([..]/library/core)
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[RUNNING] `[..] rustc --crate-name build_script_build [..]/compiler_builtins/build.rs [..]`
[RUNNING] `[ROOT]/foo/target/debug/build/compiler_builtins-[HASH]/build-script-build`
[RUNNING] `[..] rustc --crate-name compiler_builtins [..]--target aarch64-unknown-none[..]`
[RUNNING] `[..] rustc --crate-name core [..]--target aarch64-unknown-none[..]`
[RUNNING] `[..] rustc --crate-name foo [..]--target aarch64-unknown-none[..]`
Expand Down Expand Up @@ -456,6 +458,9 @@ fn build_std_with_no_arg_for_core_only_target() {
[COMPILING] rustc-std-workspace-alloc v1.9.0 ([..]/library/rustc-std-workspace-alloc)
[COMPILING] registry-dep-using-alloc v1.0.0
[COMPILING] std v0.1.0 ([..]/library/std)
[RUNNING] `[..] rustc --crate-name build_script_build [..]/compiler_builtins/build.rs [..]`
[RUNNING] `[ROOT]/foo/target/debug/build/compiler_builtins-[HASH]/build-script-build`
[RUNNING] `[ROOT]/foo/target/debug/build/compiler_builtins-[HASH]/build-script-build`
[RUNNING] `[..]rustc --crate-name compiler_builtins [..]--target aarch64-unknown-none[..]`
[RUNNING] `[..]rustc --crate-name core [..]--target aarch64-unknown-none[..]`
[RUNNING] `[..]rustc --crate-name foo [..]--target aarch64-unknown-none[..]`
Expand Down Expand Up @@ -866,3 +871,22 @@ fn fetch() {
.with_stderr_does_not_contain("[DOWNLOADED] [..]")
.run();
}

#[cargo_test(build_std_mock)]
fn std_build_script_metadata_propagate_to_user() {
let setup = setup();

let p = project()
.file("src/lib.rs", "")
.file(
"build.rs",
r#"
fn main() {
assert_eq!(std::env::var("DEP_COMPILER_RT_COMPILER_RT").unwrap(), "foo");
}
"#,
)
.build();

p.cargo("check").build_std(&setup).target_host().run();
}