summaryrefslogtreecommitdiffstats
path: root/lib/tsan/Makefile.old
blob: b548f5d2f6eedb4666664223fa13cbee6ceeac07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
DEBUG=0
LDFLAGS=-ldl -lpthread -pie
CXXFLAGS = -fPIE -fno-rtti -g -Wall -Werror \
					 -DGTEST_HAS_RTTI=0 -DTSAN_DEBUG=$(DEBUG) -DSANITIZER_DEBUG=$(DEBUG)
CLANG=clang
FILECHECK=FileCheck
# Silence warnings that Clang produces for gtest code.
# Use -Wno-attributes so that gcc doesn't complain about unknown warning types.
CXXFLAGS += -Wno-attributes
ifeq ($(DEBUG), 0)
	CXXFLAGS += -O3
endif
ifeq ($(CXX), $(CLANG)++)
  CXXFLAGS+= -Wno-unused-private-field -Wno-static-in-inline -Wgnu
endif

LIBTSAN=rtl/libtsan.a
GTEST_ROOT=third_party/googletest
GTEST_INCLUDE=-I$(GTEST_ROOT)/include
GTEST_BUILD_DIR=$(GTEST_ROOT)/build
GTEST_LIB_NAME=gtest-all.o
GTEST_LIB=$(GTEST_BUILD_DIR)/$(GTEST_LIB_NAME)

SANITIZER_COMMON_TESTS_SRC=$(wildcard ../sanitizer_common/tests/*_test.cc)
SANITIZER_COMMON_TESTS_OBJ=$(patsubst %.cc,%.o,$(SANITIZER_COMMON_TESTS_SRC))
RTL_TEST_SRC=$(wildcard tests/rtl/*.cc)
RTL_TEST_OBJ=$(patsubst %.cc,%.o,$(RTL_TEST_SRC))
UNIT_TEST_SRC=$(wildcard tests/unit/*_test.cc)
UNIT_TEST_OBJ=$(patsubst %.cc,%.o,$(UNIT_TEST_SRC))
UNIT_TEST_HDR=$(wildcard rtl/*.h) $(wildcard ../sanitizer_common/*.h)

INCLUDES=-Irtl -I.. -I../../include $(GTEST_INCLUDE)

all: libtsan test

help:
	@ echo "A little help is always welcome!"
	@ echo "The most useful targets are:"
	@ echo "  make install_deps  # Install third-party dependencies required for building"
	@ echo "  make presubmit     # Run it every time before committing"
	@ echo
	@ echo "For more info, see http://code.google.com/p/thread-sanitizer/wiki/Development"

$(LIBTSAN): libtsan

libtsan:
	$(MAKE) -C rtl -f Makefile.old DEBUG=$(DEBUG)

%.o: %.cc $(UNIT_TEST_HDR) $(LIBTSAN)
	$(CXX) $(CXXFLAGS) $(CFLAGS) $(INCLUDES) -o $@ -c $<

tsan_test: $(UNIT_TEST_OBJ) $(RTL_TEST_OBJ) \
           $(SANITIZER_COMMON_TESTS_OBJ) $(LIBTSAN) $(GTEST_LIB)
	$(CXX) $^ -o $@ $(LDFLAGS)

test: libtsan tsan_test

run: all
	(ulimit -s 8192; ./tsan_test)
	CC=$(CLANG) CXX=$(CLANG)++ FILECHECK=$(FILECHECK) ./lit_tests/test_output.sh

presubmit:
	../sanitizer_common/scripts/check_lint.sh
	# Debug build with clang.
	$(MAKE) -f Makefile.old clean
	$(MAKE) -f Makefile.old run DEBUG=1 -j 16 CC=$(CLANG) CXX=$(CLANG)++
	# Release build with clang.
	$(MAKE) -f Makefile.old clean
	$(MAKE) -f Makefile.old run DEBUG=0 -j 16 CC=$(CLANG) CXX=$(CLANG)++
	# Debug build with gcc
	$(MAKE) -f Makefile.old clean
	$(MAKE) -f Makefile.old run DEBUG=1 -j 16 CC=gcc CXX=g++
	# Release build with gcc
	$(MAKE) -f Makefile.old clean
	$(MAKE) -f Makefile.old run DEBUG=0 -j 16 CC=gcc CXX=g++
	./check_analyze.sh
	# Sanity check for Go runtime
	(cd go && ./buildgo.sh)
	# Check cmake build
	./check_cmake.sh
	@ echo PRESUBMIT PASSED

install_deps:
	rm -rf third_party
	mkdir third_party
	(cd third_party && \
	svn co -r613 http://googletest.googlecode.com/svn/trunk googletest \
        )

$(GTEST_LIB):
	mkdir -p $(GTEST_BUILD_DIR) && \
	cd $(GTEST_BUILD_DIR) && \
	$(MAKE) -f ../make/Makefile CXXFLAGS="$(CXXFLAGS)" CFLAGS="$(CFLAGS)" CC=$(CC) CXX=$(CXX) $(GTEST_LIB_NAME)

clean:
	rm -f asm_*.s libtsan.nm libtsan.objdump */*.o tsan_test
	rm -rf $(GTEST_BUILD_DIR)
	$(MAKE) clean -C rtl -f Makefile.old
	rm -f go/*.s
	rm -rf build
OpenPOWER on IntegriCloud