diff --git a/CMakeLists.txt b/CMakeLists.txt index a8bea16b..ff5cbba9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ option(BUILD_INLINE_HEADERS "Build header for inlining whole SLEEF functions" OF option(SLEEF_TEST_ALL_IUT "Perform tests on implementations with all vector extensions" OFF) option(SLEEF_SHOW_CONFIG "Show SLEEF configuration status messages." ON) option(SLEEF_SHOW_ERROR_LOG "Show cmake error log." OFF) +option(SLEEF_ASAN "Enable address sanitizing on all targets." OFF) option(ENFORCE_TESTER "Build fails if tester is not available" OFF) option(ENFORCE_TESTER3 "Build fails if tester3 is not built" OFF) diff --git a/Configure.cmake b/Configure.cmake index dcecbfc5..f31e7b98 100644 --- a/Configure.cmake +++ b/Configure.cmake @@ -85,6 +85,13 @@ if(NOT CMAKE_BUILD_TYPE) "Debug" "Release" "RelWithDebInfo" "MinSizeRel") endif() +# Sanitizers +if(SLEEF_ASAN) + # Add address sanitizing to all targets + add_compile_options(-fno-omit-frame-pointer -fsanitize=address) + add_link_options(-fno-omit-frame-pointer -fsanitize=address) +endif() + # TARGET PROCESSOR DETECTION set(SLEEF_TARGET_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}") if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_OSX_ARCHITECTURES MATCHES "^(x86_64|arm64)$")