summaryrefslogtreecommitdiffstats
path: root/src/test/run-make-fulldeps/crate-hash-rustc-version/Makefile
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/run-make-fulldeps/crate-hash-rustc-version/Makefile
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/run-make-fulldeps/crate-hash-rustc-version/Makefile')
-rw-r--r--src/test/run-make-fulldeps/crate-hash-rustc-version/Makefile37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/test/run-make-fulldeps/crate-hash-rustc-version/Makefile b/src/test/run-make-fulldeps/crate-hash-rustc-version/Makefile
new file mode 100644
index 000000000..091508cd8
--- /dev/null
+++ b/src/test/run-make-fulldeps/crate-hash-rustc-version/Makefile
@@ -0,0 +1,37 @@
+-include ../../run-make-fulldeps/tools.mk
+
+# Ensure that crates compiled with different rustc versions cannot
+# be dynamically linked.
+
+FLAGS := -Cprefer-dynamic -Zsymbol-mangling-version=v0
+UNAME := $(shell uname)
+ifeq ($(UNAME),Linux)
+ EXT=".so"
+ NM_CMD := nm -D
+endif
+ifeq ($(UNAME),Darwin)
+ EXT=".dylib"
+ NM_CMD := nm
+endif
+
+ifndef NM_CMD
+all:
+ exit 0
+else
+all:
+ # a.rs is a dylib
+ $(RUSTC) a.rs --crate-type=dylib $(FLAGS)
+ # Write symbols to disk.
+ $(NM_CMD) $(call DYLIB,a) > $(TMPDIR)/symbolsbefore
+ # b.rs is a binary
+ $(RUSTC) b.rs --extern a=$(TMPDIR)/liba$(EXT) --crate-type=bin -Crpath $(FLAGS)
+ $(call RUN,b)
+ # Now re-compile a.rs with another rustc version
+ RUSTC_FORCE_RUSTC_VERSION=deadfeed $(RUSTC) a.rs --crate-type=dylib $(FLAGS)
+ # After compiling with a different rustc version, write symbols to disk again.
+ $(NM_CMD) $(call DYLIB,a) > $(TMPDIR)/symbolsafter
+ # As a sanity check, test if the symbols changed:
+ # If the symbols are identical, there's been an error.
+ if diff $(TMPDIR)/symbolsbefore $(TMPDIR)/symbolsafter; then exit 1; fi
+ $(call FAIL,b)
+endif