2 LDFLAGS=-ldl -lrt -lpthread -pie
3 CXXFLAGS = -std=c++11 -fPIE -fno-rtti -g -Wall -Werror \
4 -DGTEST_HAS_RTTI=0 -DTSAN_DEBUG=$(DEBUG) -DSANITIZER_DEBUG=$(DEBUG)
7 # Silence warnings that Clang produces for gtest code.
8 # Use -Wno-attributes so that gcc doesn't complain about unknown warning types.
9 CXXFLAGS += -Wno-attributes
13 ifeq ($(CXX), $(CLANG)++)
14 CXXFLAGS+= -Wno-unused-private-field -Wno-static-in-inline -Wgnu
18 GTEST_ROOT=third_party/googletest
19 GTEST_INCLUDE=-I$(GTEST_ROOT)/include
20 GTEST_BUILD_DIR=$(GTEST_ROOT)/build
21 GTEST_LIB_NAME=gtest-all.o
22 GTEST_LIB=$(GTEST_BUILD_DIR)/$(GTEST_LIB_NAME)
24 SANITIZER_TESTS_PATH=../sanitizer_common/tests
25 SANITIZER_COMMON_TESTS_SRC=$(wildcard $(SANITIZER_TESTS_PATH)/*_test.cc)
26 SANITIZER_COMMON_EXCLUDED_TESTS=$(SANITIZER_TESTS_PATH)/sanitizer_nolibc_test.cc
27 SANITIZER_COMMON_GOOD_TESTS=$(filter-out $(SANITIZER_COMMON_EXCLUDED_TESTS), $(SANITIZER_COMMON_TESTS_SRC))
28 SANITIZER_COMMON_TESTS_OBJ=$(patsubst %.cc,%.o,$(SANITIZER_COMMON_GOOD_TESTS))
29 RTL_TEST_SRC=$(wildcard tests/rtl/*.cc)
30 RTL_TEST_OBJ=$(patsubst %.cc,%.o,$(RTL_TEST_SRC))
31 UNIT_TEST_SRC=$(wildcard tests/unit/*_test.cc)
32 UNIT_TEST_OBJ=$(patsubst %.cc,%.o,$(UNIT_TEST_SRC))
33 UNIT_TEST_HDR=$(wildcard rtl/*.h) $(wildcard ../sanitizer_common/*.h)
34 LIT_TESTS_PATH=../../test/tsan
36 INCLUDES=-Irtl -I.. -I../../include $(GTEST_INCLUDE)
41 @ echo "A little help is always welcome!"
42 @ echo "The most useful targets are:"
43 @ echo " make install_deps # Install third-party dependencies required for building"
44 @ echo " make presubmit # Run it every time before committing"
46 @ echo "For more info, see http://code.google.com/p/thread-sanitizer/wiki/Development"
51 $(MAKE) -C rtl -f Makefile.old DEBUG=$(DEBUG)
53 %.o: %.cc $(UNIT_TEST_HDR) $(LIBTSAN)
54 $(CXX) $(CXXFLAGS) $(CFLAGS) $(INCLUDES) -o $@ -c $<
56 tsan_test: $(UNIT_TEST_OBJ) $(RTL_TEST_OBJ) \
57 $(SANITIZER_COMMON_TESTS_OBJ) $(LIBTSAN) $(GTEST_LIB)
58 $(CXX) -Wl,--whole-archive $^ -Wl,--no-whole-archive -o $@ $(LDFLAGS)
60 test: libtsan tsan_test
63 (ulimit -s 8192; ./tsan_test)
64 CC=$(CLANG) CXX=$(CLANG)++ FILECHECK=$(FILECHECK) $(LIT_TESTS_PATH)/test_output.sh
67 ../sanitizer_common/scripts/check_lint.sh
68 # Debug build with clang.
69 $(MAKE) -f Makefile.old clean
70 $(MAKE) -f Makefile.old run DEBUG=1 -j 16 CC=$(CLANG) CXX=$(CLANG)++
71 # Release build with clang.
72 $(MAKE) -f Makefile.old clean
73 $(MAKE) -f Makefile.old run DEBUG=0 -j 16 CC=$(CLANG) CXX=$(CLANG)++
75 # Debug build with gcc
76 $(MAKE) -f Makefile.old clean
77 $(MAKE) -f Makefile.old run DEBUG=1 -j 16 CC=gcc CXX=g++
78 # Release build with gcc
79 $(MAKE) -f Makefile.old clean
80 $(MAKE) -f Makefile.old run DEBUG=0 -j 16 CC=gcc CXX=g++
83 # Sanity check for Go runtime
84 (cd go && ./buildgo.sh)
87 @ echo PRESUBMIT PASSED
93 svn co -r613 http://googletest.googlecode.com/svn/trunk googletest \
97 mkdir -p $(GTEST_BUILD_DIR) && \
98 cd $(GTEST_BUILD_DIR) && \
99 $(MAKE) -f ../make/Makefile CXXFLAGS="$(CXXFLAGS)" CFLAGS="$(CFLAGS)" CC=$(CC) CXX=$(CXX) $(GTEST_LIB_NAME)
102 rm -f asm_*.s libtsan.nm libtsan.objdump */*.o tsan_test
103 rm -rf $(GTEST_BUILD_DIR)
104 $(MAKE) clean -C rtl -f Makefile.old