summaryrefslogtreecommitdiffstats
path: root/tests/run-make/no-cdylib-as-rdylib/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run-make/no-cdylib-as-rdylib/Makefile')
-rw-r--r--tests/run-make/no-cdylib-as-rdylib/Makefile16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/run-make/no-cdylib-as-rdylib/Makefile b/tests/run-make/no-cdylib-as-rdylib/Makefile
new file mode 100644
index 000000000..4d2be0aea
--- /dev/null
+++ b/tests/run-make/no-cdylib-as-rdylib/Makefile
@@ -0,0 +1,16 @@
+# 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)