btrfs-progs: build: Enable ThreadSanitizer, using D=tsan

Tested with clang-3.9. We have to enable PIE,
(https://clang.llvm.org/docs/ThreadSanitizer.html)

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Adam Buchbinder 2017-07-12 13:04:49 -07:00 committed by David Sterba
parent e2fd79c243
commit 18aed6a623
1 changed files with 6 additions and 0 deletions

View File

@ -17,6 +17,7 @@
# abort - call abort() on first error (dumps core) # abort - call abort() on first error (dumps core)
# all - shortcut for all of the above # all - shortcut for all of the above
# asan - enable address sanitizer compiler feature # asan - enable address sanitizer compiler feature
# tsan - enable thread sanitizer compiler feature
# ubsan - undefined behaviour sanitizer compiler feature # ubsan - undefined behaviour sanitizer compiler feature
# bcheck - extended build checks # bcheck - extended build checks
# W=123 build with warnings (default: off) # W=123 build with warnings (default: off)
@ -157,6 +158,11 @@ ifneq (,$(findstring asan,$(D)))
DEBUG_CFLAGS_INTERNAL += -fsanitize=address DEBUG_CFLAGS_INTERNAL += -fsanitize=address
endif endif
ifneq (,$(findstring tsan,$(D)))
DEBUG_CFLAGS_INTERNAL += -fsanitize=thread -fPIE
LD_FLAGS += -fsanitize=thread -ltsan -pie
endif
ifneq (,$(findstring ubsan,$(D))) ifneq (,$(findstring ubsan,$(D)))
DEBUG_CFLAGS_INTERNAL += -fsanitize=undefined DEBUG_CFLAGS_INTERNAL += -fsanitize=undefined
endif endif