From de1a13418344989e9dc25fd3b49e61627e1389e8 Mon Sep 17 00:00:00 2001 From: Alexander Haase Date: Wed, 6 Apr 2016 19:32:45 +0200 Subject: [PATCH] Check if MemorySanitizer is used on x86_64 Linux. According to the MemorySanitizer documentation, it is only compatible with 64bit Linux at the moment. --- cmake/FindMSan.cmake | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cmake/FindMSan.cmake b/cmake/FindMSan.cmake index ac9a290..bdc2c2c 100644 --- a/cmake/FindMSan.cmake +++ b/cmake/FindMSan.cmake @@ -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 ()