From ece7d98c0ea5b639c59331ef6b2c890c637ef862 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 14 Jun 2024 13:22:51 -0400 Subject: [PATCH] rewrite mixing-libs to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/mixing-libs/Makefile | 8 ------- tests/run-make/mixing-libs/rmake.rs | 21 +++++++++++++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) delete mode 100644 tests/run-make/mixing-libs/Makefile create mode 100644 tests/run-make/mixing-libs/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 23b3b91604dc6..6c67155b55cff 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -90,7 +90,6 @@ run-make/manual-link/Makefile run-make/metadata-dep-info/Makefile run-make/min-global-align/Makefile run-make/missing-crate-dependency/Makefile -run-make/mixing-libs/Makefile run-make/native-link-modifier-bundle/Makefile run-make/native-link-modifier-whole-archive/Makefile run-make/no-alloc-shim/Makefile diff --git a/tests/run-make/mixing-libs/Makefile b/tests/run-make/mixing-libs/Makefile deleted file mode 100644 index 459db0dfdb2f7..0000000000000 --- a/tests/run-make/mixing-libs/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -all: - $(RUSTC) rlib.rs --crate-type=rlib --crate-type=dylib - $(RUSTC) dylib.rs # no -Cprefer-dynamic so statically linking librlib.rlib - $(call REMOVE_DYLIBS,rlib) # remove librlib.so to test that prog.rs doesn't get confused about the removed dylib version of librlib - $(RUSTC) prog.rs && exit 1 || exit 0 diff --git a/tests/run-make/mixing-libs/rmake.rs b/tests/run-make/mixing-libs/rmake.rs new file mode 100644 index 0000000000000..d46a2403c25b3 --- /dev/null +++ b/tests/run-make/mixing-libs/rmake.rs @@ -0,0 +1,21 @@ +// Having multiple upstream crates available in different formats +// should result in failed compilation. This test causes multiple +// libraries to exist simultaneously as rust libs and dynamic libs, +// causing prog.rs to fail compilation. +// See https://github.com/rust-lang/rust/issues/10434 + +//@ ignore-cross-compile + +use run_make_support::{remove_dylibs, rustc}; + +fn main() { + rustc().input("rlib.rs").crate_type("rlib").crate_type("dylib").run(); + + // Not putting `-C prefer-dynamic` here allows for static linking of librlib.rlib. + rustc().input("dylib.rs").run(); + + // librlib's dynamic version needs to be removed here to prevent prog.rs from fetching + // the wrong one. + remove_dylibs("rlib"); + rustc().input("prog.rs").run_fail(); +}