Skip to content

Commit c0997e5

Browse files
committed
rewrite redundant-libs to rmake
1 parent b9e844f commit c0997e5

File tree

4 files changed

+35
-26
lines changed

4 files changed

+35
-26
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ run-make/pgo-gen-lto/Makefile
3939
run-make/pgo-indirect-call-promotion/Makefile
4040
run-make/print-calling-conventions/Makefile
4141
run-make/print-target-list/Makefile
42-
run-make/redundant-libs/Makefile
4342
run-make/remap-path-prefix-dwarf/Makefile
4443
run-make/reproducible-build-2/Makefile
4544
run-make/reproducible-build/Makefile

tests/run-make/raw-dylib-c/rmake.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ fn main() {
2525
.actual_text("actual", out_driver)
2626
.normalize(r#"\r"#, "")
2727
.run();
28-
diff().expected_file("output.txt").actual_text("actual", out_raw).run();
28+
diff().expected_file("output.txt").actual_text("actual", out_raw).normalize(r#"\r"#, "").run();
2929
}

tests/run-make/redundant-libs/Makefile

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// rustc will remove one of the two redundant references to foo below. Depending
2+
// on which one gets removed, we'll get a linker error on SOME platforms (like
3+
// Linux). On these platforms, when a library is referenced, the linker will
4+
// only pull in the symbols needed _at that point in time_. If a later library
5+
// depends on additional symbols from the library, they will not have been pulled
6+
// in, and you'll get undefined symbols errors.
7+
//
8+
// So in this example, we need to ensure that rustc keeps the _later_ reference
9+
// to foo, and not the former one.
10+
11+
//@ ignore-cross-compile
12+
// Reason: the compiled binary is executed
13+
//@ ignore-windows-msvc
14+
// Reason: this test links libraries via link.exe, which only accepts the import library
15+
// for the dynamic library, i.e. `foo.dll.lib`. However, build_native_dynamic_lib only
16+
// produces `foo.dll` - the dynamic library itself. To make this test work on MSVC, one
17+
// would need to derive the import library from the dynamic library.
18+
// See https://stackoverflow.com/questions/9360280/
19+
20+
use run_make_support::{
21+
build_native_dynamic_lib, build_native_static_lib, cwd, is_msvc, rfs, run, rustc,
22+
};
23+
24+
fn main() {
25+
build_native_dynamic_lib("foo");
26+
build_native_static_lib("bar");
27+
build_native_static_lib("baz");
28+
rustc()
29+
.args(&["-lstatic=bar", "-lfoo", "-lstatic=baz", "-lfoo"])
30+
.input("main.rs")
31+
.print("link-args")
32+
.run();
33+
run("main");
34+
}

0 commit comments

Comments
 (0)