Preserve optimization setting for sanitizer build

This commit is contained in:
Jon Siwek 2020-01-07 20:58:19 -08:00
parent 0c55b01ec9
commit 3273169385
5 changed files with 22 additions and 10 deletions

View file

@ -130,13 +130,21 @@ if ( ZEEK_SANITIZERS )
set(_sanitizer_flags "${_sanitizer_flags} -fno-omit-frame-pointer")
set(_sanitizer_flags "${_sanitizer_flags} -fno-optimize-sibling-calls")
if ( NOT DEFINED ENV{NO_OPTIMIZATIONS} )
# Using -O1 is generally the suggestion to get more reasonable
# performance. The one downside is it that the compiler may optimize out
# code that otherwise generates an error/leak in a -O0 build, but that
# should be rare and users mostly will not be running unoptimized builds
# in production anyway.
set(_sanitizer_flags "${_sanitizer_flags} -O1")
if ( NOT DEFINED ZEEK_SANITIZER_OPTIMIZATIONS )
if ( DEFINED ENV{NO_OPTIMIZATIONS} )
# Using -O1 is generally the suggestion to get more reasonable
# performance. The one downside is it that the compiler may
# optimize out code that otherwise generates an error/leak in a -O0
# build, but that should be rare and users mostly will not be
# running unoptimized builds in production anyway.
set(ZEEK_SANITIZER_OPTIMIZATIONS false CACHE INTERNAL "" FORCE)
else ()
set(ZEEK_SANITIZER_OPTIMIZATIONS true CACHE INTERNAL "" FORCE)
endif ()
endif ()
if ( ZEEK_SANITIZER_OPTIMIZATIONS )
set(_sanitizer_flags "${_sanitizer_flags} -O1")
endif ()
# Technically, the we also need to use the compiler to drive linking and