]> git.lizzy.rs Git - rust.git/blob - tests/run-make-fulldeps/crate-hash-rustc-version/Makefile
Rollup merge of #106113 - krasimirgg:llvm-16-ext-tyid, r=nikic
[rust.git] / tests / run-make-fulldeps / crate-hash-rustc-version / Makefile
1 include ../../run-make-fulldeps/tools.mk
2
3 # Ensure that crates compiled with different rustc versions cannot
4 # be dynamically linked.
5
6 FLAGS := -Cprefer-dynamic -Zsymbol-mangling-version=v0
7 UNAME := $(shell uname)
8 ifeq ($(UNAME),Linux)
9   EXT=".so"
10   NM_CMD := nm -D
11 endif
12 ifeq ($(UNAME),Darwin)
13   EXT=".dylib"
14   NM_CMD := nm
15 endif
16
17 ifndef NM_CMD
18 all:
19         exit 0
20 else
21 all:
22         # a.rs is a dylib
23         $(RUSTC) a.rs --crate-type=dylib $(FLAGS)
24         # Write symbols to disk.
25         $(NM_CMD) $(call DYLIB,a) > $(TMPDIR)/symbolsbefore
26         # b.rs is a binary
27         $(RUSTC) b.rs --extern a=$(TMPDIR)/liba$(EXT) --crate-type=bin -Crpath $(FLAGS)
28         $(call RUN,b)
29         # Now re-compile a.rs with another rustc version
30         RUSTC_FORCE_RUSTC_VERSION=deadfeed $(RUSTC) a.rs --crate-type=dylib $(FLAGS)
31         # After compiling with a different rustc version, write symbols to disk again.
32         $(NM_CMD) $(call DYLIB,a) > $(TMPDIR)/symbolsafter
33         # As a sanity check, test if the symbols changed:
34         # If the symbols are identical, there's been an error.
35         if diff $(TMPDIR)/symbolsbefore $(TMPDIR)/symbolsafter; then exit 1; fi
36         $(call FAIL,b)
37 endif