Skip to content

Commit 4b3aa08

Browse files
committed
Add thread sanitizer option to cmake
---------------------------------------------- Thread sanitizer (TSAN) is a tool that detect data races, deadlocks between threads. (it also sometimes report heap-use-after-free in same thread check #71 for issues reported in current repo) For more information, checkout https://clang.llvm.org/docs/ThreadSanitizer.html
1 parent ef694d7 commit 4b3aa08

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ if(ACL_CODE_COVERAGE)
6868
endif()
6969
endif()
7070

71+
# Flag for tsan scans
72+
option(ACL_TSAN "Build with tsan" OFF)
73+
message(STATUS "Build with tsan: ${ACL_TSAN}")
74+
if(ACL_TSAN)
75+
if(CMAKE_COMPILER_IS_GNUCXX)
76+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
77+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
78+
else()
79+
message(FATAL_ERROR "cannot build with tsan tools due to unsupported CXX compiler")
80+
endif()
81+
endif()
82+
7183
################################################################################
7284
### Modified Debug flags
7385
################################################################################

0 commit comments

Comments
 (0)