Skip to content

Commit

Permalink
run-make: enable msvc for link-dedup
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDenton committed Aug 4, 2024
1 parent b389b0a commit 74c9235
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions tests/run-make/link-dedup/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,36 @@
// 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

Check failure on line 24 in tests/run-make/link-dedup/rmake.rs

View workflow job for this annotation

GitHub Actions / PR - mingw-check-tidy

line longer than 100 chars
// https://github.com/rust-lang/rust/pull/103311
//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() {
_ = needle.write_fmt(format_args!(r#""{lib}.lib" "#));
} else {
_ = needle.write_fmt(format_args!(r#""-l{lib}" "#));
}
}
needle.pop(); // remove trailing space
needle
}

0 comments on commit 74c9235

Please sign in to comment.