|
5 | 5 | // Without the --cfg flag, there should be a single -ltesta, no more, no less.
|
6 | 6 | // See https://github.com/rust-lang/rust/pull/84794
|
7 | 7 |
|
8 |
| -//@ ignore-msvc |
| 8 | +use std::fmt::Write; |
9 | 9 |
|
10 |
| -use run_make_support::rustc; |
| 10 | +use run_make_support::{is_msvc, rustc}; |
11 | 11 |
|
12 | 12 | fn main() {
|
13 | 13 | rustc().input("depa.rs").run();
|
14 | 14 | rustc().input("depb.rs").run();
|
15 | 15 | rustc().input("depc.rs").run();
|
| 16 | + |
16 | 17 | 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 | + |
22 | 20 | 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 |
24 | 41 | }
|
0 commit comments