cmake/scons: if sanitizers are enabled, also add -fno-omit-frame-pointer and -fno-optimize-sibling-calls.

Otherwise, if we build with sanitizers and optimizations, the sanitizer stacktraces can become quite hard to read.

(cherry-picked from commit 29089a4736)
This commit is contained in:
Matthias Krüger 2018-04-22 13:04:19 +02:00 committed by Pentarctagon
parent bf8b0220e5
commit 4c5e74b2da
2 changed files with 5 additions and 2 deletions

View file

@ -232,6 +232,8 @@ endif(ENABLE_PEDANTIC_COMPILATION)
if(SANITIZE)
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fsanitize=${SANITIZE}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${SANITIZE}")
# manually disable some optimizations to get better stacktraces if sanitizers are used
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls")
endif(SANITIZE)
### Set the final compiler flags.

View file

@ -481,7 +481,8 @@ for env in [test_env, client_env, env]:
env.AppendUnique(CXXFLAGS = Split("-Wctor-dtor-privacy -Wuseless-cast -Wnoexcept"))
if env['sanitize']:
env.AppendUnique(CCFLAGS = ["-fsanitize=" + env["sanitize"]], LINKFLAGS = ["-fsanitize=" + env["sanitize"]])
env.AppendUnique(CCFLAGS = Split("-fno-omit-frame-pointer -fno-optimize-sibling-calls"))
# #
# Determine optimization level
# #
@ -494,7 +495,7 @@ for env in [test_env, client_env, env]:
else:
env["opt"] = "-O0 "
else:
env["opt"] = env["opt"]+" "
env["opt"] = env["opt"]+" "
# #
# Start determining options for debug build