Skip to content

Commit c354b53

Browse files
committed
Add test case for current behavior.
1 parent 428f8f4 commit c354b53

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/testsuite/build_script.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6087,3 +6087,40 @@ fn directory_with_leading_underscore() {
60876087
.with_status(0)
60886088
.run();
60896089
}
6090+
6091+
#[cargo_test]
6092+
fn linker_search_path_preference() {
6093+
// This isn't strictly the exact scenario that causes the issue, but it's the shortest demonstration
6094+
// of the issue.
6095+
let p = project()
6096+
.file(
6097+
"Cargo.toml",
6098+
r#"
6099+
[package]
6100+
name = "foo"
6101+
version = "0.1.0"
6102+
edition = "2024"
6103+
build = "build.rs"
6104+
"#,
6105+
)
6106+
.file(
6107+
"build.rs",
6108+
r#"
6109+
fn main() {
6110+
let out_dir = std::env::var("OUT_DIR").unwrap();
6111+
println!("cargo::rustc-link-search=/usr/lib");
6112+
println!("cargo::rustc-link-search={}/libs2", out_dir);
6113+
println!("cargo::rustc-link-search=/lib");
6114+
println!("cargo::rustc-link-search={}/libs1", out_dir);
6115+
}
6116+
"#,
6117+
)
6118+
.file("src/main.rs", "fn main() {}")
6119+
.build();
6120+
6121+
p.cargo("build -v").with_stderr_data(str![[r#"
6122+
...
6123+
[RUNNING] `rustc --crate-name foo [..] -L /usr/lib -L [ROOT]/foo/target/debug/build/foo-[HASH]/out/libs2 -L /lib -L [ROOT]/foo/target/debug/build/foo-[HASH]/out/libs1`
6124+
...
6125+
"#]]).run();
6126+
}

0 commit comments

Comments
 (0)