Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
fix: sanitizer options don't take effect (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
foreverneverer authored and Wu Tao committed Dec 19, 2019
1 parent 55634c4 commit 8095786
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 8 additions & 8 deletions bin/dsn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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.")
Expand Down
3 changes: 2 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 8095786

Please sign in to comment.