Skip to content

Commit 011727f

Browse files
committed
rewrite redundant-libs to rmake
1 parent f31f8c4 commit 011727f

File tree

5 files changed

+41
-28
lines changed

5 files changed

+41
-28
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ run-make/no-alloc-shim/Makefile
2323
run-make/pdb-buildinfo-cl-cmd/Makefile
2424
run-make/pgo-gen-lto/Makefile
2525
run-make/pgo-indirect-call-promotion/Makefile
26-
run-make/redundant-libs/Makefile
2726
run-make/remap-path-prefix-dwarf/Makefile
2827
run-make/reproducible-build-2/Makefile
2928
run-make/reproducible-build/Makefile

tests/run-make/raw-dylib-alt-calling-convention/rmake.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ fn main() {
2020
rustc().crate_type("bin").input("driver.rs").run();
2121
build_native_dynamic_lib("extern");
2222
let out = run("driver").stdout_utf8();
23-
diff().expected_file("output.txt").actual_text("actual", out).run();
23+
diff().expected_file("output.txt").actual_text("actual", out).normalize(r#"\r"#, "").run();
2424
if is_msvc() {
2525
let out_msvc = run_with_args("driver", &["true"]).stdout_utf8();
26-
diff().expected_file("output.msvc.txt").actual_text("actual", out_msvc).run();
26+
diff()
27+
.expected_file("output.msvc.txt")
28+
.actual_text("actual", out_msvc)
29+
.normalize(r#"\r"#, "")
30+
.run();
2731
}
2832
}

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

+1-1
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

-24
This file was deleted.
+34
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)