Skip to content

Commit 5f44f95

Browse files
committed
rewrite link-dedup to rmake
1 parent 553204d commit 5f44f95

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ run-make/libtest-padding/Makefile
111111
run-make/libtest-thread-limit/Makefile
112112
run-make/link-args-order/Makefile
113113
run-make/link-cfg/Makefile
114-
run-make/link-dedup/Makefile
115114
run-make/link-framework/Makefile
116115
run-make/link-path-order/Makefile
117116
run-make/linkage-attr-on-static/Makefile

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

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// When native libraries are passed to the linker, there used to be an annoyance
2+
// where multiple instances of the same library in a row would cause duplication in
3+
// outputs. This has been fixed, and this test checks that it stays fixed.
4+
// With the --cfg flag, -ltestb gets added to the output, breaking up the chain of -ltesta.
5+
// Without the --cfg flag, there should be a single -ltesta, no more, no less.
6+
// See https://github.com/rust-lang/rust/pull/84794
7+
8+
//@ ignore-msvc
9+
10+
fn main() {
11+
rustc().input("depa.rs").run();
12+
rustc().input("depb.rs").run();
13+
rustc().input("depc.rs").run();
14+
let output =
15+
String::from_utf8(rustc().input("empty.rs").cfg("bar").command_output().stderr).unwrap();
16+
let pos_a1 =
17+
output.find("-ltesta").expect("empty.rs, compiled with --cfg, should contain -ltesta");
18+
let pos_b = output[pos_a1..]
19+
.find("-ltestb")
20+
.map(|pos| pos + pos_a1)
21+
.expect("empty.rs, compiled with --cfg, should contain -ltestb");
22+
let _ = output[pos_b..]
23+
.find("-ltesta")
24+
.map(|pos| pos + pos_b)
25+
.expect("empty.rs, compiled with --cfg, should contain a second -ltesta");
26+
let output = String::from_utf8(rustc().input("empty.rs").command_output().stderr).unwrap();
27+
assert!(output.contains("-ltesta"));
28+
let output = String::from_utf8(rustc().input("empty.rs").command_output().stderr).unwrap();
29+
assert!(!output.contains("-ltestb"));
30+
let output = String::from_utf8(rustc().input("empty.rs").command_output().stderr).unwrap();
31+
assert_eq!(output.matches("-ltesta").count, 1);
32+
}

0 commit comments

Comments
 (0)