diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index d742368292035..fc2ba589d2442 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -185,7 +185,6 @@ run-make/native-link-modifier-whole-archive/Makefile run-make/no-alloc-shim/Makefile run-make/no-builtins-attribute/Makefile run-make/no-builtins-lto/Makefile -run-make/no-cdylib-as-rdylib/Makefile run-make/no-duplicate-libs/Makefile run-make/no-intermediate-extras/Makefile run-make/obey-crate-type-flag/Makefile diff --git a/tests/run-make/no-cdylib-as-rdylib/Makefile b/tests/run-make/no-cdylib-as-rdylib/Makefile deleted file mode 100644 index 4d2be0aea913d..0000000000000 --- a/tests/run-make/no-cdylib-as-rdylib/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# Test that rustc will not attempt to link against a cdylib as if -# it is a rust dylib when an rlib for the same crate is available. -# Previously rustc didn't actually check if any further formats of -# a crate which has been loaded are of the same version and if -# they are actually valid. This caused a cdylib to be interpreted -# as rust dylib as soon as the corresponding rlib was loaded. As -# cdylibs don't export any rust symbols, linking would fail if -# rustc decides to link against the cdylib rather than the rlib. - -all: - $(RUSTC) bar.rs --crate-type=rlib --crate-type=cdylib - $(RUSTC) foo.rs -C prefer-dynamic - $(call RUN,foo) diff --git a/tests/run-make/no-cdylib-as-rdylib/rmake.rs b/tests/run-make/no-cdylib-as-rdylib/rmake.rs new file mode 100644 index 0000000000000..42e89df6c2b61 --- /dev/null +++ b/tests/run-make/no-cdylib-as-rdylib/rmake.rs @@ -0,0 +1,16 @@ +// This test produces an rlib and a cdylib from bar.rs. +// Then, foo.rs attempts to link to the bar library. +// If the test passes, that means rustc favored the rlib and ignored the cdylib. +// If the test fails, that is because the cdylib was picked, which does not export +// any Rust symbols. +// See https://github.com/rust-lang/rust/pull/113695 + +//@ ignore-cross-compile + +use run_make_support::{run, rustc}; + +fn main() { + rustc().input("bar.rs").crate_type("rlib").crate_type("cdylib").run(); + rustc().input("foo.rs").arg("-Cprefer-dynamic").run(); + run("foo"); +}