Skip to content

Commit

Permalink
Check if ThreadSanitizer is used on x86_64 Linux.
Browse files Browse the repository at this point in the history
According to the ThreadSanitizer documentation, it is only compatible with 64bit
Linux at the moment.
  • Loading branch information
alehaa committed Apr 6, 2016
1 parent 03db9d9 commit 4d96db3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cmake/FindTSan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,22 @@ set(FLAG_CANDIDATES

include(sanitize-helpers)

sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "ThreadSanitizer" "TSan")
if (SANITIZE_THREAD)
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
message(WARNING "ThreadSanitizer disabled for target ${TARGET} because "
"ThreadSanitizer is supported for Linux systems only.")
set(SANITIZE_THREAD Off CACHE BOOL
"Enable ThreadSanitizer for sanitized targets." FORCE)
elseif (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8)
message(WARNING "ThreadSanitizer disabled for target ${TARGET} because "
"ThreadSanitizer is supported for 64bit systems only.")
set(SANITIZE_THREAD Off CACHE BOOL
"Enable ThreadSanitizer for sanitized targets." FORCE)
else ()
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "ThreadSanitizer"
"TSan")
endif ()
endif ()

function (add_sanitize_thread TARGET)
if (NOT SANITIZE_THREAD)
Expand Down

0 comments on commit 4d96db3

Please sign in to comment.