diff options
| author | Trevor Gross <t.gross35@gmail.com> | 2024-08-06 22:17:33 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-06 22:17:33 -0500 |
| commit | cc42e3439186d0f159d1f69bf200e8c51f1b3169 (patch) | |
| tree | 45c69dd5a2d16063c6d8043bca6b19d0403e0394 | |
| parent | b3bfd666273dcfd2f3d036f6a27ff5affc96558b (diff) | |
| parent | d8c2b767c6a18780a617d82c6a232253e447e5db (diff) | |
Rollup merge of #128638 - ChrisDenton:link-dedup, r=jieyouxu
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
| -rw-r--r-- | tests/run-make/link-dedup/rmake.rs | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/tests/run-make/link-dedup/rmake.rs b/tests/run-make/link-dedup/rmake.rs index 9bff3a4b44c..6075f310954 100644 --- a/tests/run-make/link-dedup/rmake.rs +++ b/tests/run-make/link-dedup/rmake.rs @@ -5,20 +5,37 @@ // Without the --cfg flag, there should be a single -ltesta, no more, no less. // See https://github.com/rust-lang/rust/pull/84794 -//@ ignore-msvc +use std::fmt::Write; -use run_make_support::rustc; +use run_make_support::{is_msvc, rustc}; fn main() { rustc().input("depa.rs").run(); rustc().input("depb.rs").run(); rustc().input("depc.rs").run(); + let output = rustc().input("empty.rs").cfg("bar").run_fail(); - output.assert_stderr_contains(r#""-ltesta" "-ltestb" "-ltesta""#); - let output = rustc().input("empty.rs").run_fail(); - output.assert_stderr_contains(r#""-ltesta""#); - let output = rustc().input("empty.rs").run_fail(); - output.assert_stderr_not_contains(r#""-ltestb""#); + output.assert_stderr_contains(needle_from_libs(&["testa", "testb", "testa"])); + let output = rustc().input("empty.rs").run_fail(); - output.assert_stderr_not_contains(r#""-ltesta" "-ltesta" "-ltesta""#); + output.assert_stderr_contains(needle_from_libs(&["testa"])); + output.assert_stderr_not_contains(needle_from_libs(&["testb"])); + output.assert_stderr_not_contains(needle_from_libs(&["testa", "testa", "testa"])); + // Adjacent identical native libraries are no longer deduplicated if + // they come from different crates (https://github.com/rust-lang/rust/pull/103311) + // so the following will fail: + //output.assert_stderr_not_contains(needle_from_libs(&["testa", "testa"])); +} + +fn needle_from_libs(libs: &[&str]) -> String { + let mut needle = String::new(); + for lib in libs { + if is_msvc() { + let _ = needle.write_fmt(format_args!(r#""{lib}.lib" "#)); + } else { + let _ = needle.write_fmt(format_args!(r#""-l{lib}" "#)); + } + } + needle.pop(); // remove trailing space + needle } |
