2012-05-10 23:10:03 +08:00
|
|
|
DEBUG=0
|
|
|
|
LDFLAGS=-ldl -lpthread -pie
|
2012-06-14 22:02:32 +08:00
|
|
|
CXXFLAGS = -fPIE -g -Wall -Werror -DTSAN_DEBUG=$(DEBUG)
|
2012-06-19 15:38:11 +08:00
|
|
|
# Silence warnings that Clang produces for gtest code.
|
|
|
|
# Use -Wno-attributes so that gcc doesn't complain about unknown warning types.
|
2012-06-30 01:32:18 +08:00
|
|
|
CXXFLAGS += -Wno-attributes
|
2012-05-10 23:10:03 +08:00
|
|
|
ifeq ($(DEBUG), 0)
|
|
|
|
CXXFLAGS += -O3
|
|
|
|
endif
|
2012-06-30 00:37:49 +08:00
|
|
|
ifeq ($(CXX), clang++)
|
2012-06-30 01:32:18 +08:00
|
|
|
CXXFLAGS+= -Wno-unused-private-field -Wno-static-in-inline
|
2012-06-30 00:37:49 +08:00
|
|
|
endif
|
2012-05-10 23:10:03 +08:00
|
|
|
|
|
|
|
LIBTSAN=rtl/libtsan.a
|
|
|
|
GTEST_ROOT=third_party/googletest
|
|
|
|
GTEST_INCLUDE=-I$(GTEST_ROOT)/include
|
|
|
|
GTEST_BUILD_DIR=$(GTEST_ROOT)/build
|
|
|
|
GTEST_LIB=$(GTEST_BUILD_DIR)/gtest-all.o
|
|
|
|
|
2012-07-19 00:04:55 +08:00
|
|
|
SANITIZER_COMMON_TESTS_SRC=$(wildcard ../sanitizer_common/tests/*_test.cc)
|
2012-06-20 23:19:17 +08:00
|
|
|
SANITIZER_COMMON_TESTS_OBJ=$(patsubst %.cc,%.o,$(SANITIZER_COMMON_TESTS_SRC))
|
2012-05-10 23:10:03 +08:00
|
|
|
RTL_TEST_SRC=$(wildcard rtl_tests/*.cc)
|
|
|
|
RTL_TEST_OBJ=$(patsubst %.cc,%.o,$(RTL_TEST_SRC))
|
|
|
|
UNIT_TEST_SRC=$(wildcard unit_tests/*_test.cc)
|
|
|
|
UNIT_TEST_OBJ=$(patsubst %.cc,%.o,$(UNIT_TEST_SRC))
|
2012-06-21 18:04:36 +08:00
|
|
|
UNIT_TEST_HDR=$(wildcard rtl/*.h) $(wildcard ../sanitizer_common/*.h)
|
2012-05-10 23:10:03 +08:00
|
|
|
|
2012-06-05 15:46:31 +08:00
|
|
|
INCLUDES=-Irtl -I.. $(GTEST_INCLUDE)
|
2012-05-10 23:10:03 +08:00
|
|
|
|
2012-05-17 16:33:14 +08:00
|
|
|
all: libtsan test
|
2012-05-10 23:10:03 +08:00
|
|
|
|
|
|
|
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 " make lint # Run the style checker"
|
|
|
|
@ echo
|
|
|
|
@ echo "For more info, see http://code.google.com/p/data-race-test/wiki/ThreadSanitizer2"
|
|
|
|
|
2012-05-17 16:33:14 +08:00
|
|
|
$(LIBTSAN): libtsan
|
|
|
|
|
|
|
|
libtsan:
|
2012-05-10 23:10:03 +08:00
|
|
|
$(MAKE) -C rtl -f Makefile.old DEBUG=$(DEBUG)
|
|
|
|
|
2012-07-19 00:04:55 +08:00
|
|
|
%.o: %.cc $(UNIT_TEST_HDR) $(LIBTSAN)
|
2012-05-28 22:15:39 +08:00
|
|
|
$(CXX) $(CXXFLAGS) $(CFLAGS) $(INCLUDES) -o $@ -c $<
|
2012-05-10 23:10:03 +08:00
|
|
|
|
2012-07-02 22:35:25 +08:00
|
|
|
tsan_test: $(UNIT_TEST_OBJ) $(RTL_TEST_OBJ) \
|
2012-06-20 23:19:17 +08:00
|
|
|
$(SANITIZER_COMMON_TESTS_OBJ) $(LIBTSAN) $(GTEST_LIB)
|
2012-05-10 23:10:03 +08:00
|
|
|
$(CXX) $^ -o $@ $(LDFLAGS)
|
|
|
|
|
2012-05-17 16:33:14 +08:00
|
|
|
test: libtsan tsan_test
|
2012-05-10 23:10:03 +08:00
|
|
|
|
|
|
|
run: all
|
|
|
|
(ulimit -s 8192; ./tsan_test)
|
2012-05-11 22:42:24 +08:00
|
|
|
./output_tests/test_output.sh
|
2012-05-10 23:10:03 +08:00
|
|
|
|
|
|
|
presubmit:
|
|
|
|
$(MAKE) -f Makefile.old lint -j 4
|
|
|
|
# Debug build with clang.
|
|
|
|
$(MAKE) -f Makefile.old clean
|
|
|
|
$(MAKE) -f Makefile.old run DEBUG=1 -j 16 CC=clang CXX=clang++
|
2012-05-11 22:42:24 +08:00
|
|
|
# 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
|
2012-05-10 23:10:03 +08:00
|
|
|
$(MAKE) -f Makefile.old clean
|
|
|
|
$(MAKE) -f Makefile.old run DEBUG=0 -j 16 CC=gcc CXX=g++
|
|
|
|
./check_analyze.sh
|
|
|
|
@ echo PRESUBMIT PASSED
|
|
|
|
|
2012-05-29 20:18:18 +08:00
|
|
|
RTL_LINT_FITLER=-legal/copyright,-build/include,-readability/casting,-build/header_guard,-build/namespaces
|
2012-05-10 23:10:03 +08:00
|
|
|
|
|
|
|
lint: lint_tsan lint_tests
|
|
|
|
lint_tsan:
|
2012-06-20 23:19:17 +08:00
|
|
|
third_party/cpplint/cpplint.py --filter=$(RTL_LINT_FITLER) rtl/*.{cc,h} \
|
|
|
|
../sanitizer_common/*.{cc,h}
|
2012-05-10 23:10:03 +08:00
|
|
|
lint_tests:
|
2012-06-20 23:19:17 +08:00
|
|
|
third_party/cpplint/cpplint.py --filter=$(RTL_LINT_FITLER) \
|
|
|
|
rtl_tests/*.{cc,h} unit_tests/*.cc ../sanitizer_common/tests/*.cc
|
2012-05-10 23:10:03 +08:00
|
|
|
|
|
|
|
install_deps:
|
|
|
|
rm -rf third_party
|
|
|
|
mkdir third_party
|
|
|
|
(cd third_party && \
|
|
|
|
svn co -r613 http://googletest.googlecode.com/svn/trunk googletest && \
|
|
|
|
svn co -r82 http://google-styleguide.googlecode.com/svn/trunk/cpplint cpplint \
|
|
|
|
)
|
|
|
|
|
|
|
|
# Remove verbose printf from lint. Not strictly necessary.
|
|
|
|
hack_cpplint:
|
|
|
|
sed -i "s/ sys.stderr.write('Done processing.*//g" third_party/cpplint/cpplint.py
|
|
|
|
|
|
|
|
$(GTEST_LIB):
|
|
|
|
mkdir -p $(GTEST_BUILD_DIR) && \
|
|
|
|
cd $(GTEST_BUILD_DIR) && \
|
|
|
|
$(MAKE) -f ../make/Makefile CXXFLAGS="$(CXXFLAGS)" CFLAGS="$(CFLAGS)" CC=$(CC) CXX=$(CXX)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f asm_*.s libtsan.nm libtsan.objdump */*.o tsan_test
|
|
|
|
rm -rf $(GTEST_BUILD_DIR)
|
|
|
|
$(MAKE) clean -C rtl -f Makefile.old
|