Skip to content

Commit

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

include(sanitize-helpers)

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

function (add_sanitize_memory TARGET)
if (NOT SANITIZE_THREAD)
if (NOT SANITIZE_MEMORY)
return()
endif ()

Expand Down

0 comments on commit de1a134

Please sign in to comment.