Skip to content

Commit d8c2b76

Browse files
committed
run-make: enable msvc for link-dedup
1 parent b389b0a commit d8c2b76

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

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

+25-8
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,37 @@
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
25+
// they come from different crates (https://github.com/rust-lang/rust/pull/103311)
26+
// so the following will fail:
27+
//output.assert_stderr_not_contains(needle_from_libs(&["testa", "testa"]));
28+
}
29+
30+
fn needle_from_libs(libs: &[&str]) -> String {
31+
let mut needle = String::new();
32+
for lib in libs {
33+
if is_msvc() {
34+
let _ = needle.write_fmt(format_args!(r#""{lib}.lib" "#));
35+
} else {
36+
let _ = needle.write_fmt(format_args!(r#""-l{lib}" "#));
37+
}
38+
}
39+
needle.pop(); // remove trailing space
40+
needle
2441
}

0 commit comments

Comments
 (0)