From 2b85595f22a4e1ca4b9428acebdecd736521eef4 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 11 Jul 2023 10:31:43 +0200 Subject: [PATCH] MSan: check that not UBSan and ASan set; check that clang set --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c29105d503..cc3ee6d89b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -255,6 +255,12 @@ endif () add_boolean_option(SANITIZE_MEMORY False "enable the memory sanitizer (MSan, requires clang, incompatible with ASan/UBSan)" ON) if(SANITIZE_MEMORY) + if (SANITIZE_UNDEFINED OR SANITIZE_ADDRESS) + message(FATAL_ERROR "memory sanitizer cannot coexist with address sanitizer or undefined behavior sanitizer, please disable either MSan or ASan and UBSan") + endif() + if (NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" ) + message(FATAL_ERROR "memory sanitizer requires clang, please set clang using CC=/usr/bin/clang CXX=/usr/bin/clang++ ./build_oai ...") + endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -fsanitize-recover=memory") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -fsanitize-recover=memory") endif()