Skip to content

Commit

Permalink
Enable/disable address sanitizer with CMake (shibatch#507)
Browse files Browse the repository at this point in the history
...on all targets
  • Loading branch information
blapie authored Jan 25, 2024
1 parent 6c0ad2d commit df84fc7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions Configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)$")
Expand Down

0 comments on commit df84fc7

Please sign in to comment.