Skip to content
Snippets Groups Projects
Commit 706b8ccc authored by David Fairbrother's avatar David Fairbrother
Browse files

Fix sanitizers not switching off and leak env var

Fixes sanitizers not switching off if USE_SANITIZER was set to off.
Additionally gets rid of a space between LSAN_OPTIONS and the actual
options, which was causing the suppressions file to be ignored.
parent 18407c4b
No related branches found
No related tags found
No related merge requests found
......@@ -212,7 +212,7 @@ macro(CXXTEST_ADD_TEST _cxxtest_testname)
set( _LSAN_OPTS "suppressions=${SUPPRESSIONS_DIR}/Leak.supp" )
set_property( TEST ${_cxxtest_separate_name} APPEND PROPERTY
ENVIRONMENT LSAN_OPTIONS= ${_LSAN_OPTS} )
ENVIRONMENT LSAN_OPTIONS=${_LSAN_OPTS} )
endif()
......
......@@ -34,30 +34,29 @@ if(NOT ${USE_SANITIZERS_LOWER} MATCHES "off")
add_compile_options(-fno-omit-frame-pointer -fno-optimize-sibling-calls)
endif()
# Allow all instrumented code to continue beyond the first error
add_compile_options(-fsanitize-recover=all)
# Address
add_compile_options(
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"address">:-fsanitize=address>)
add_link_options(
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"address">:-fsanitize=address>)
# Thread
add_compile_options(
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"thread">:-fsanitize=thread>)
add_link_options(
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"thread">:-fsanitize=thread>)
# Undefined
# RTTI information is not exported for some classes causing the
# linker to fail whilst adding vptr instrumentation
add_compile_options(
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"undefined">:-fsanitize=undefined>
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"undefined">:-fno-sanitize=vptr>)
add_link_options(
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"undefined">:-fsanitize=undefined>)
endif()
# Allow all instrumented code to continue beyond the first error
add_compile_options($<$<NOT:$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"off">>:-fsanitize-recover=all>)
# Address
add_compile_options(
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"address">:-fsanitize=address>)
add_link_options(
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"address">:-fsanitize=address>)
# Thread
add_compile_options(
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"thread">:-fsanitize=thread>)
add_link_options(
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"thread">:-fsanitize=thread>)
# Undefined
# RTTI information is not exported for some classes causing the
# linker to fail whilst adding vptr instrumentation
add_compile_options(
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"undefined">:-fsanitize=undefined>
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"undefined">:-fno-sanitize=vptr>)
add_link_options(
$<$<STREQUAL:$<LOWER_CASE:"${USE_SANITIZER}">,"undefined">:-fsanitize=undefined>)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment