about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-05-13 23:30:50 -0400
committerOneirical <manchot@videotron.ca>2024-05-14 17:02:20 -0400
commit1f61cc3078ce6bcca8095778310f73fc45f7193e (patch)
tree1886a67cf7fa4ec3f4c134ffa7b09577ec6dccb0
parentd25cf6fc14cb74e9d892d2b13701dafbdf9f5cac (diff)
downloadrust-1f61cc3078ce6bcca8095778310f73fc45f7193e.tar.gz
rust-1f61cc3078ce6bcca8095778310f73fc45f7193e.zip
port no-cdylib-as-rdylib test
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/no-cdylib-as-rdylib/Makefile16
-rw-r--r--tests/run-make/no-cdylib-as-rdylib/rmake.rs16
3 files changed, 16 insertions, 17 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index d7423682920..fc2ba589d24 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 4d2be0aea91..00000000000
--- 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 00000000000..42e89df6c2b
--- /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");
+}