Skip to content

Commit f6220e2

Browse files
committed
Auto merge of #128638 - ChrisDenton:link-dedup, r=<try>
run-make: enable msvc for `link-dedup` This is just a case of differing style of linker arguments. I also cleaned up a bit where we were running the same command three times in a row. Instead I reused the output. One thing that confused me is why we were testing for the same lib three times in a row but not two. After figuring that out I added a note to hopefully save future readers some confusion. try-job: x86_64-msvc try-job: i686-msvc
2 parents b389b0a + 74c9235 commit f6220e2

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

tests/run-make/link-dedup/rmake.rs

+24-8
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,36 @@
55
// Without the --cfg flag, there should be a single -ltesta, no more, no less.
66
// See https://github.com/rust-lang/rust/pull/84794
77

8-
//@ ignore-msvc
8+
use std::fmt::Write;
99

10-
use run_make_support::rustc;
10+
use run_make_support::{is_msvc, rustc};
1111

1212
fn main() {
1313
rustc().input("depa.rs").run();
1414
rustc().input("depb.rs").run();
1515
rustc().input("depc.rs").run();
16+
1617
let output = rustc().input("empty.rs").cfg("bar").run_fail();
17-
output.assert_stderr_contains(r#""-ltesta" "-ltestb" "-ltesta""#);
18-
let output = rustc().input("empty.rs").run_fail();
19-
output.assert_stderr_contains(r#""-ltesta""#);
20-
let output = rustc().input("empty.rs").run_fail();
21-
output.assert_stderr_not_contains(r#""-ltestb""#);
18+
output.assert_stderr_contains(needle_from_libs(&["testa", "testb", "testa"]));
19+
2220
let output = rustc().input("empty.rs").run_fail();
23-
output.assert_stderr_not_contains(r#""-ltesta" "-ltesta" "-ltesta""#);
21+
output.assert_stderr_contains(needle_from_libs(&["testa"]));
22+
output.assert_stderr_not_contains(needle_from_libs(&["testb"]));
23+
output.assert_stderr_not_contains(needle_from_libs(&["testa", "testa", "testa"]));
24+
// Adjacent identical native libraries are no longer deduplicated if they come from different crates
25+
// https://github.com/rust-lang/rust/pull/103311
26+
//output.assert_stderr_not_contains(needle_from_libs(&["testa", "testa"]));
27+
}
28+
29+
fn needle_from_libs(libs: &[&str]) -> String {
30+
let mut needle = String::new();
31+
for lib in libs {
32+
if is_msvc() {
33+
_ = needle.write_fmt(format_args!(r#""{lib}.lib" "#));
34+
} else {
35+
_ = needle.write_fmt(format_args!(r#""-l{lib}" "#));
36+
}
37+
}
38+
needle.pop(); // remove trailing space
39+
needle
2440
}

0 commit comments

Comments
 (0)