rust/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile

23 lines
845 B
Makefile
Raw Normal View History

-include ../tools.mk
LOG := $(TMPDIR)/log.txt
# This test builds a shared object, then an executable that links it as a native
2018-08-19 08:30:23 -05:00
# rust library (contrast to an rlib). The shared library and executable both
# are compiled with address sanitizer, and we assert that a fault in the dylib
# is correctly detected.
ifeq ($(TARGET),x86_64-unknown-linux-gnu)
ASAN_SUPPORT=$(RUSTC_SANITIZER_SUPPORT)
# See comment in sanitizer-address/Makefile for why this is here
EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic
endif
all:
ifeq ($(ASAN_SUPPORT),1)
$(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs
$(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow
endif