From 04bd2bdb747956eae898df20f6659fae5d3e72ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 24 Apr 2020 21:17:06 +0200 Subject: [PATCH] some sanitizer build fixes and cleanups (#2621) * cleaned up sanitizer build flags * exprengine.cpp: work around linker error with Clang and UBSAN --- cmake/dynamic_analyzer_options.cmake | 9 +++++---- lib/exprengine.cpp | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmake/dynamic_analyzer_options.cmake b/cmake/dynamic_analyzer_options.cmake index a6c536a8a..a87babc2b 100644 --- a/cmake/dynamic_analyzer_options.cmake +++ b/cmake/dynamic_analyzer_options.cmake @@ -2,12 +2,13 @@ if(ANALYZE_MEMORY) add_compile_options(-fsanitize=memory) add_compile_options(-fsanitize-memory-track-origins=2) add_compile_options(-fno-omit-frame-pointer) - # NOTE: tail call elimination -fno-optimize-sibling-calls + add_compile_options(-fno-optimize-sibling-calls) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory") elseif(ANALYZE_ADDRESS) add_compile_options(-fsanitize=address) add_compile_options(-fno-omit-frame-pointer) + add_compile_options(-fno-optimize-sibling-calls) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") elseif(ANALYZE_THREAD) @@ -17,9 +18,9 @@ elseif(ANALYZE_THREAD) endif() if(ANALYZE_UNDEFINED) - add_compile_options(-fsanitize=undefined-trap) - add_compile_options(-fsanitize-undefined-trap-on-error) - add_compile_options(-fno-sanitize-recover) + add_compile_options(-fsanitize=undefined) + add_compile_options(-fno-sanitize-recover=all) + add_compile_options(-fno-omit-frame-pointer) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined") endif() diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index c68e0ad7f..bb8b5b220 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -318,6 +318,10 @@ namespace { }; } +#ifdef __clang__ +// work around "undefined reference to `__muloti4'" linker error - see https://bugs.llvm.org/show_bug.cgi?id=16404 +__attribute__((no_sanitize("undefined"))) +#endif static ExprEngine::ValuePtr simplifyValue(ExprEngine::ValuePtr origValue) { auto b = std::dynamic_pointer_cast(origValue);