diff options
author | Stephan Beyer <s-beyer@gmx.net> | 2020-05-18 20:54:09 +0300 |
---|---|---|
committer | Stephan Beyer <s-beyer@gmx.net> | 2020-05-19 11:57:58 +0300 |
commit | 7f598b181e51f0f733b9f041df553053103da375 (patch) | |
tree | 923e742022cc9ea66cd955b5c46803559e664655 /cmake | |
parent | 00574ef8b482787d060ca5dfd254e86b7ea85e3c (diff) |
Add -fno-sanitize=vptr for SANITIZE_UNDEFINED=ON
The UndefinedBehaviorSanitizer includes the "vptr" check. This
check, however, needs typeinfo for OCC::AccountManager because
otherwise its stub for FileManTest leads to undefined references
when linking. Adding the -frtti flag to enable run-time typeinfo
did not solve the problem. I do not know another solution, so this
commit disables the vptr check.
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/SanitizerFlags.cmake | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/cmake/modules/SanitizerFlags.cmake b/cmake/modules/SanitizerFlags.cmake index 433190182..d4818873c 100644 --- a/cmake/modules/SanitizerFlags.cmake +++ b/cmake/modules/SanitizerFlags.cmake @@ -1,11 +1,16 @@ # Enable address sanitizer (gcc/clang only) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") set(SANITIZERS) + set(SANITIZER_EXTRA_FLAGS " -g") macro(add_sanitizer_option variable flag help) option(${variable} "Enable ${help}" OFF) if(${variable}) list(APPEND SANITIZERS ${flag}) + string(REPLACE ";" " " optional_args "${ARGN}") + if(optional_args) + string(APPEND SANITIZER_EXTRA_FLAGS " ${optional_args}") + endif() endif() mark_as_advanced(${variable}) endmacro() @@ -17,13 +22,14 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") add_sanitizer_option(SANITIZE_MEMORY "memory" "MemorySanitizer (detects reads in uninitialized memory)") add_sanitizer_option(SANITIZE_UNDEFINED "undefined" - "UndefinedBehaviorSanitizer (detects undefined behavior)") + "UndefinedBehaviorSanitizer (detects undefined behavior)" + "-fno-sanitize=vptr") add_sanitizer_option(SANITIZE_THREAD "thread" "ThreadSanitizer (detects data races)") if(SANITIZERS) string(REPLACE ";" "," SANITIZER_FLAGS "${SANITIZERS}") - set(SANITIZER_FLAGS "-fsanitize=${SANITIZER_FLAGS}") + set(SANITIZER_FLAGS "-fsanitize=${SANITIZER_FLAGS}${SANITIZER_EXTRA_FLAGS}") string(APPEND CMAKE_CXX_FLAGS " ${SANITIZER_FLAGS}") string(APPEND CMAKE_C_FLAGS " ${SANITIZER_FLAGS}") string(APPEND CMAKE_EXE_LINKER_FLAGS " ${SANITIZER_FLAGS}") |