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