diff options
author | Christian Ulmann <christianulmann@gmail.com> | 2024-09-11 16:11:10 +0200 |
---|---|---|
committer | Christian Ulmann <christianulmann@gmail.com> | 2024-09-11 16:16:23 +0200 |
commit | 9ac511312d7f458367fc72b6ac9ec304b1574fc8 (patch) | |
tree | 9482378b2b88fa99d9424be25406bc71cac1783a | |
parent | aa2a5abff7b3c7790f4863abae504f3cd426b35b (diff) | |
download | llvm-users/dinistro/asan-compile-option.zip llvm-users/dinistro/asan-compile-option.tar.gz llvm-users/dinistro/asan-compile-option.tar.bz2 |
add #error for ASAN mismatch with DYLIB offusers/dinistro/asan-compile-option
-rw-r--r-- | llvm/cmake/modules/HandleLLVMOptions.cmake | 7 | ||||
-rw-r--r-- | llvm/include/llvm/Config/llvm-config.h.cmake | 3 | ||||
-rw-r--r-- | llvm/include/llvm/Support/Compiler.h | 14 |
3 files changed, 12 insertions, 12 deletions
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index cec18e3..f36df8b 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -1052,13 +1052,6 @@ if(LLVM_USE_SANITIZER) endif() endif() -# Add a compile option to indicate if LLVM is building with address sanitizers. -if(LLVM_ADDRESS_SANITIZER_BUILD) - add_compile_definitions(LLVM_ADDRESS_SANITIZER_BUILD=1) -else() - add_compile_definitions(LLVM_ADDRESS_SANITIZER_BUILD=0) -endif() - # Turn on -gsplit-dwarf if requested in debug builds. if (LLVM_USE_SPLIT_DWARF AND ((uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") OR diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake index 6605ea6..f026d38 100644 --- a/llvm/include/llvm/Config/llvm-config.h.cmake +++ b/llvm/include/llvm/Config/llvm-config.h.cmake @@ -198,4 +198,7 @@ /* Define if plugins enabled */ #cmakedefine LLVM_ENABLE_PLUGINS +/* Define if LLVM is build with address sanitizers enabled */ +#cmakedefine01 LLVM_ADDRESS_SANITIZER_BUILD + #endif diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h index 4212128..9bb3b90 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -436,12 +436,16 @@ # define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE #endif -/// \macro LLVM_ADDRESS_SANITIZER_BUILD -/// Whether LLVM itself is built with AddressSanitizer instrumentation. -#ifndef LLVM_ADDRESS_SANITIZER_BUILD -# define LLVM_ADDRESS_SANITIZER_BUILD 0 -#endif #if LLVM_ADDRESS_SANITIZER_BUILD + +// These kind of sanitizer mismatches can lead to sporadic false positives that +// are very hard to debug. +#if !defined(LLVM_BUILD_LLVM_DYLIB) && \ + !__has_feature(address_sanitizer) && \ + !defined(__SANITIZE_ADDRESS__) +#error An address sanitized LLVM build cannot be combined with unsanitized code. +#endif + #if __has_include(<sanitizer/asan_interface.h>) # include <sanitizer/asan_interface.h> #else |