Skip to content

Commit 5d72321

Browse files
committed
rewrite redundant-libs to rmake
1 parent 0a69501 commit 5d72321

File tree

4 files changed

+30
-26
lines changed

4 files changed

+30
-26
lines changed

src/tools/run-make-support/src/external_deps/c_build.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ pub fn build_native_static_lib(lib_name: &str) -> PathBuf {
3535
pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf {
3636
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
3737
let src = format!("{lib_name}.c");
38-
let lib_path = dynamic_lib_name(lib_name);
38+
let lib_path =
39+
if is_msvc() { format!("{lib_name}.dll.lib") } else { dynamic_lib_name(lib_name) };
3940
if is_msvc() {
4041
cc().arg("-c").out_exe(&obj_file).input(src).run();
4142
} else {

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ run-make/print-target-list/Makefile
4545
run-make/raw-dylib-import-name-type/Makefile
4646
run-make/raw-dylib-link-ordinal/Makefile
4747
run-make/raw-dylib-stdcall-ordinal/Makefile
48-
run-make/redundant-libs/Makefile
4948
run-make/remap-path-prefix-dwarf/Makefile
5049
run-make/reproducible-build-2/Makefile
5150
run-make/reproducible-build/Makefile

tests/run-make/redundant-libs/Makefile

-24
This file was deleted.
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
14+
//FIXME(Oneirical): msvc
15+
16+
use run_make_support::{build_native_dynamic_lib, build_native_static_lib, run, rustc};
17+
18+
fn main() {
19+
build_native_dynamic_lib("foo");
20+
build_native_static_lib("bar");
21+
build_native_static_lib("baz");
22+
rustc()
23+
.input("main.rs")
24+
.args(&["-lstatic=bar", "-lfoo", "-lstatic=baz", "-lfoo"])
25+
.print("link-args")
26+
.run();
27+
run("main");
28+
}

0 commit comments

Comments
 (0)