From 8095786262560324f871ac2a831acbdbb138d0df Mon Sep 17 00:00:00 2001 From: Shuo Date: Thu, 19 Dec 2019 10:02:38 +0800 Subject: [PATCH] fix: sanitizer options don't take effect (#360) --- bin/dsn.cmake | 16 ++++++++-------- run.sh | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/dsn.cmake b/bin/dsn.cmake index 0bad3dde7c..9bc1864956 100644 --- a/bin/dsn.cmake +++ b/bin/dsn.cmake @@ -173,7 +173,6 @@ endfunction() function(dsn_setup_compiler_flags) if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions(-DDSN_BUILD_TYPE=Debug) - #for sanitizer add_definitions(-g) else() add_definitions(-g) @@ -186,10 +185,7 @@ function(dsn_setup_compiler_flags) # We want access to the PRI* print format macros. add_definitions(-D__STDC_FORMAT_MACROS) - # -fno-omit-frame-pointer - # use frame pointers to allow simple stack frame walking for backtraces. - # This has a small perf hit but worth it for the ability to profile in production - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -fno-omit-frame-pointer" CACHE STRING "" FORCE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y" CACHE STRING "" FORCE) # -Wall: Enable all warnings. add_compile_options(-Wall) @@ -203,6 +199,10 @@ function(dsn_setup_compiler_flags) add_compile_options(-Wno-deprecated-declarations) add_compile_options(-Wno-inconsistent-missing-override) add_compile_options(-Wno-attributes) + # -fno-omit-frame-pointer + # use frame pointers to allow simple stack frame walking for backtraces. + # This has a small perf hit but worth it for the ability to profile in production + add_compile_options( -fno-omit-frame-pointer) find_program(CCACHE_FOUND ccache) if(CCACHE_FOUND) @@ -222,8 +222,8 @@ function(dsn_setup_compiler_flags) endif() message(STATUS "Running cmake with sanitizer=${SANITIZER}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${SANITIZER}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${SANITIZER}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${SANITIZER}" CACHE STRING "" FORCE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${SANITIZER}" CACHE STRING "" FORCE) endif() set(CMAKE_EXE_LINKER_FLAGS @@ -300,7 +300,7 @@ function(dsn_setup_thirdparty_libs) endfunction(dsn_setup_thirdparty_libs) function(dsn_common_setup) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(notdir $(abspath $<))\"'") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(notdir $(abspath $<))\"'" CACHE STRING "" FORCE) if(NOT (UNIX)) message(FATAL_ERROR "Only Unix are supported.") diff --git a/run.sh b/run.sh index 9e95f372d5..113ce53a87 100755 --- a/run.sh +++ b/run.sh @@ -65,7 +65,8 @@ function usage_build() } function run_build() { - #NOTE(jiashuo1): No memory check mode, because MemorySanitizer is only available in Clang for Linux x86_64 targets + # NOTE(jiashuo1): No "memory" check mode, because MemorySanitizer is only available in Clang for Linux x86_64 targets + # https://www.jetbrains.com/help/clion/google-sanitizers.html SANITIZERS=("address" "leak" "thread" "undefined") C_COMPILER="gcc"