cmake/nc_sanitizer.cmake

20 lines
817 B
CMake
Raw Permalink Normal View History

option (SANITIZER "enable sanitizers" OFF)
if (SANITIZER)
append_compile_flag("-fsanitize=undefined")
append_compile_flag("-fsanitize=address")
append_compile_flag("-fsanitize=leak")
append_compile_flag("--param max-gcse-memory=167772160")
2022-07-26 06:58:11 +10:00
# Don't enable pointer-compare as https://github.com/google/sanitizers/issues/1324
# states it isn't production-ready and it results in some link errors under (at least) gcc-11.3
# eg, undefined reference to 'std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::_M_high_mark()
# See also: https://github.com/cms-sw/cmssw/issues/36480
#
#append_compile_flag("-fsanitize=pointer-compare")
append_compile_flag("-fsanitize=pointer-subtract")
add_definitions("-D_GLIBCXX_SANITIZE_VECTOR")
2022-07-26 06:58:11 +10:00
endif()