1 CXXFLAGS = -fPIE -g -Wall -Werror -fno-builtin -DTSAN_DEBUG=$(DEBUG) -DSANITIZER_DEBUG=$(DEBUG) 2 ifeq ($(DEBUG), 0) 3 CXXFLAGS += -O3 4 endif 5 ifeq ($(CXX), clang++) 6 CXXFLAGS+= -Wgnu 7 endif 8 9 # For interception. FIXME: move interception one level higher. 10 INTERCEPTION=../../interception 11 COMMON=../../sanitizer_common 12 INCLUDES= -I../.. -I../../../include 13 EXTRA_CXXFLAGS=-fno-exceptions -fno-rtti 14 NO_SYSROOT=--sysroot=. 15 CXXFLAGS+=$(EXTRA_CXXFLAGS) 16 CXXFLAGS+=$(CFLAGS) 17 ifeq ($(DEBUG), 0) 18 CXXFLAGS+=-fomit-frame-pointer 19 ifeq ($(CXX), g++) 20 CXXFLAGS+=-Wframe-larger-than=512 21 endif # CXX=g++ 22 endif # DEBUG=0 23 24 ifeq ($(CXX), clang++) 25 # Global constructors are banned. 26 CXXFLAGS+=-Wglobal-constructors 27 endif 28 29 30 31 all: libtsan.a 32 33 LIBTSAN_HEADERS=$(wildcard *.h) \ 34 $(wildcard $(INTERCEPTION)/*.h) \ 35 $(wildcard $(COMMON)/*.h) 36 LIBTSAN_SRC=$(wildcard *.cc) 37 LIBTSAN_ASM_SRC=$(wildcard *.S) 38 INTERCEPTION_SRC=$(wildcard $(INTERCEPTION)/*.cc) 39 COMMON_SRC=$(wildcard $(COMMON)/*.cc) 40 41 LIBTSAN_OBJ=$(patsubst %.cc,%.o,$(LIBTSAN_SRC)) \ 42 $(patsubst %.S,%.o,$(LIBTSAN_ASM_SRC)) \ 43 $(patsubst $(INTERCEPTION)/%.cc,%.o,$(INTERCEPTION_SRC)) \ 44 $(patsubst $(COMMON)/%.cc,%.o,$(COMMON_SRC)) 45 46 %_linux.o: %_linux.cc Makefile.old $(LIBTSAN_HEADERS) 47 $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< 48 %.o: %.cc Makefile.old $(LIBTSAN_HEADERS) 49 $(CXX) $(CXXFLAGS) $(INCLUDES) $(NO_SYSROOT) -c $< 50 %.o: $(INTERCEPTION)/%.cc Makefile.old $(LIBTSAN_HEADERS) 51 $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@ 52 %.o: $(COMMON)/%.cc Makefile.old $(LIBTSAN_HEADERS) 53 $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@ 54 55 libtsan.a: $(LIBTSAN_OBJ) 56 ar ru $@ $(LIBTSAN_OBJ) 57 58 libtsan_dummy.a: tsan_dummy_rtl.o 59 ar ru $@ $< 60 61 clean: 62 rm -f *.o *.a 63