Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 1 | DEBUG=0 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 2 | LDFLAGS=-ldl -lrt -lpthread -pie |
| 3 | CXXFLAGS = -std=c++11 -fPIE -fno-rtti -g -Wall -Werror \ |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 4 | -DGTEST_HAS_RTTI=0 -DSANITIZER_DEBUG=$(DEBUG) \ |
| 5 | -DTSAN_CONTAINS_UBSAN=0 |
Alexey Samsonov | 5c88936 | 2013-03-18 07:00:36 +0000 | [diff] [blame] | 6 | CLANG=clang |
Alexey Samsonov | 6a7c51d | 2013-04-04 12:18:12 +0000 | [diff] [blame] | 7 | FILECHECK=FileCheck |
Alexey Samsonov | 0a9d891 | 2012-06-19 07:38:11 +0000 | [diff] [blame] | 8 | # Silence warnings that Clang produces for gtest code. |
| 9 | # Use -Wno-attributes so that gcc doesn't complain about unknown warning types. |
Dmitry Vyukov | a3eca81 | 2012-06-29 17:32:18 +0000 | [diff] [blame] | 10 | CXXFLAGS += -Wno-attributes |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 11 | ifeq ($(DEBUG), 0) |
| 12 | CXXFLAGS += -O3 |
| 13 | endif |
Alexey Samsonov | 5c88936 | 2013-03-18 07:00:36 +0000 | [diff] [blame] | 14 | ifeq ($(CXX), $(CLANG)++) |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 15 | CXXFLAGS += -Wno-unused-private-field -Wno-static-in-inline -Wgnu |
| 16 | else |
| 17 | CXXFLAGS += -Wno-maybe-uninitialized |
Dmitry Vyukov | aa7bb26 | 2012-06-29 16:37:49 +0000 | [diff] [blame] | 18 | endif |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 19 | |
| 20 | LIBTSAN=rtl/libtsan.a |
| 21 | GTEST_ROOT=third_party/googletest |
| 22 | GTEST_INCLUDE=-I$(GTEST_ROOT)/include |
| 23 | GTEST_BUILD_DIR=$(GTEST_ROOT)/build |
Alexey Samsonov | 1e3657c | 2012-12-19 09:19:57 +0000 | [diff] [blame] | 24 | GTEST_LIB_NAME=gtest-all.o |
| 25 | GTEST_LIB=$(GTEST_BUILD_DIR)/$(GTEST_LIB_NAME) |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 26 | |
Alexey Samsonov | 616659a | 2013-05-29 09:40:07 +0000 | [diff] [blame] | 27 | SANITIZER_TESTS_PATH=../sanitizer_common/tests |
| 28 | SANITIZER_COMMON_TESTS_SRC=$(wildcard $(SANITIZER_TESTS_PATH)/*_test.cc) |
| 29 | SANITIZER_COMMON_EXCLUDED_TESTS=$(SANITIZER_TESTS_PATH)/sanitizer_nolibc_test.cc |
| 30 | SANITIZER_COMMON_GOOD_TESTS=$(filter-out $(SANITIZER_COMMON_EXCLUDED_TESTS), $(SANITIZER_COMMON_TESTS_SRC)) |
| 31 | SANITIZER_COMMON_TESTS_OBJ=$(patsubst %.cc,%.o,$(SANITIZER_COMMON_GOOD_TESTS)) |
Alexey Samsonov | f548ef8 | 2012-09-17 10:02:17 +0000 | [diff] [blame] | 32 | RTL_TEST_SRC=$(wildcard tests/rtl/*.cc) |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 33 | RTL_TEST_OBJ=$(patsubst %.cc,%.o,$(RTL_TEST_SRC)) |
Alexey Samsonov | f548ef8 | 2012-09-17 10:02:17 +0000 | [diff] [blame] | 34 | UNIT_TEST_SRC=$(wildcard tests/unit/*_test.cc) |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 35 | UNIT_TEST_OBJ=$(patsubst %.cc,%.o,$(UNIT_TEST_SRC)) |
Kostya Serebryany | c375657 | 2012-06-21 10:04:36 +0000 | [diff] [blame] | 36 | UNIT_TEST_HDR=$(wildcard rtl/*.h) $(wildcard ../sanitizer_common/*.h) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 37 | LIT_TESTS_PATH=../../test/tsan |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 38 | |
Kostya Serebryany | 5f0297b | 2012-08-29 08:21:09 +0000 | [diff] [blame] | 39 | INCLUDES=-Irtl -I.. -I../../include $(GTEST_INCLUDE) |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 40 | |
Kostya Serebryany | 3547924 | 2012-05-17 08:33:14 +0000 | [diff] [blame] | 41 | all: libtsan test |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 42 | |
| 43 | help: |
| 44 | @ echo "A little help is always welcome!" |
| 45 | @ echo "The most useful targets are:" |
| 46 | @ echo " make install_deps # Install third-party dependencies required for building" |
| 47 | @ echo " make presubmit # Run it every time before committing" |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 48 | @ echo |
Dmitry Vyukov | b75c67b | 2012-12-19 06:59:45 +0000 | [diff] [blame] | 49 | @ echo "For more info, see http://code.google.com/p/thread-sanitizer/wiki/Development" |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 50 | |
Kostya Serebryany | 3547924 | 2012-05-17 08:33:14 +0000 | [diff] [blame] | 51 | $(LIBTSAN): libtsan |
| 52 | |
| 53 | libtsan: |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 54 | $(MAKE) -C rtl -f Makefile.old DEBUG=$(DEBUG) |
| 55 | |
Kostya Serebryany | 389b74b | 2012-07-18 16:04:55 +0000 | [diff] [blame] | 56 | %.o: %.cc $(UNIT_TEST_HDR) $(LIBTSAN) |
Dmitry Vyukov | 40565ce | 2012-05-28 14:15:39 +0000 | [diff] [blame] | 57 | $(CXX) $(CXXFLAGS) $(CFLAGS) $(INCLUDES) -o $@ -c $< |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 58 | |
Alexey Samsonov | c3d1698 | 2012-07-02 14:35:25 +0000 | [diff] [blame] | 59 | tsan_test: $(UNIT_TEST_OBJ) $(RTL_TEST_OBJ) \ |
Kostya Serebryany | 6985085 | 2012-06-20 15:19:17 +0000 | [diff] [blame] | 60 | $(SANITIZER_COMMON_TESTS_OBJ) $(LIBTSAN) $(GTEST_LIB) |
Alexey Samsonov | cac631e | 2013-09-11 11:06:06 +0000 | [diff] [blame] | 61 | $(CXX) -Wl,--whole-archive $^ -Wl,--no-whole-archive -o $@ $(LDFLAGS) |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 62 | |
Kostya Serebryany | 3547924 | 2012-05-17 08:33:14 +0000 | [diff] [blame] | 63 | test: libtsan tsan_test |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 64 | |
| 65 | run: all |
| 66 | (ulimit -s 8192; ./tsan_test) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 67 | CC=$(CLANG) CXX=$(CLANG)++ FILECHECK=$(FILECHECK) $(LIT_TESTS_PATH)/test_output.sh |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 68 | |
| 69 | presubmit: |
Dmitry Vyukov | e6867ac | 2012-12-19 08:53:31 +0000 | [diff] [blame] | 70 | ../sanitizer_common/scripts/check_lint.sh |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 71 | # Debug build with clang. |
| 72 | $(MAKE) -f Makefile.old clean |
Alexey Samsonov | 5c88936 | 2013-03-18 07:00:36 +0000 | [diff] [blame] | 73 | $(MAKE) -f Makefile.old run DEBUG=1 -j 16 CC=$(CLANG) CXX=$(CLANG)++ |
Kostya Serebryany | 3d6ae15 | 2012-05-11 14:42:24 +0000 | [diff] [blame] | 74 | # Release build with clang. |
| 75 | $(MAKE) -f Makefile.old clean |
Alexey Samsonov | 5c88936 | 2013-03-18 07:00:36 +0000 | [diff] [blame] | 76 | $(MAKE) -f Makefile.old run DEBUG=0 -j 16 CC=$(CLANG) CXX=$(CLANG)++ |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 77 | ./check_memcpy.sh |
Kostya Serebryany | 3d6ae15 | 2012-05-11 14:42:24 +0000 | [diff] [blame] | 78 | # Debug build with gcc |
| 79 | $(MAKE) -f Makefile.old clean |
| 80 | $(MAKE) -f Makefile.old run DEBUG=1 -j 16 CC=gcc CXX=g++ |
| 81 | # Release build with gcc |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 82 | $(MAKE) -f Makefile.old clean |
| 83 | $(MAKE) -f Makefile.old run DEBUG=0 -j 16 CC=gcc CXX=g++ |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 84 | ./check_memcpy.sh |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 85 | ./check_analyze.sh |
Dmitry Vyukov | ff6e6c3 | 2012-12-14 10:10:57 +0000 | [diff] [blame] | 86 | # Sanity check for Go runtime |
| 87 | (cd go && ./buildgo.sh) |
Dmitry Vyukov | 98263a1 | 2012-12-20 14:10:27 +0000 | [diff] [blame] | 88 | # Check cmake build |
| 89 | ./check_cmake.sh |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 90 | @ echo PRESUBMIT PASSED |
| 91 | |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 92 | install_deps: |
| 93 | rm -rf third_party |
| 94 | mkdir third_party |
| 95 | (cd third_party && \ |
Alexey Samsonov | 184fdd7 | 2012-08-31 08:10:28 +0000 | [diff] [blame] | 96 | svn co -r613 http://googletest.googlecode.com/svn/trunk googletest \ |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 97 | ) |
| 98 | |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 99 | $(GTEST_LIB): |
| 100 | mkdir -p $(GTEST_BUILD_DIR) && \ |
| 101 | cd $(GTEST_BUILD_DIR) && \ |
Alexey Samsonov | 1e3657c | 2012-12-19 09:19:57 +0000 | [diff] [blame] | 102 | $(MAKE) -f ../make/Makefile CXXFLAGS="$(CXXFLAGS)" CFLAGS="$(CFLAGS)" CC=$(CC) CXX=$(CXX) $(GTEST_LIB_NAME) |
Kostya Serebryany | b82ae88 | 2012-05-10 15:10:03 +0000 | [diff] [blame] | 103 | |
| 104 | clean: |
| 105 | rm -f asm_*.s libtsan.nm libtsan.objdump */*.o tsan_test |
| 106 | rm -rf $(GTEST_BUILD_DIR) |
| 107 | $(MAKE) clean -C rtl -f Makefile.old |
Alexey Samsonov | fcc7c8c | 2013-02-01 15:30:36 +0000 | [diff] [blame] | 108 | rm -f go/*.s |
Alexey Samsonov | 55249d1 | 2013-02-25 08:32:02 +0000 | [diff] [blame] | 109 | rm -rf build |