Skip to content

Commit

Permalink
init sanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingstom committed Dec 13, 2023
1 parent 50a0fd2 commit 693be15
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ cmake_minimum_required(VERSION 3.24)
project(Aphrodite)

# Provide an option to enable testing
option(APH_ENABLE_TESTING "Enable testing for the APH project" ON)
option(APH_ENABLE_TRACING "Enable tracer for the APH project" ON)
option(APH_ENABLE_TESTING "Enable testing" ON)
option(APH_ENABLE_TRACING "Enable tracer" ON)
option(APH_ENABLE_TSAN "Enable thread sanitizer" OFF)
option(APH_ENABLE_ASAN "Enable address sanitizer" OFF)
option(APH_ENABLE_MSAN "Enable memory sanitizer" OFF)

set(APH_ROOT_DIR ${CMAKE_SOURCE_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${APH_ROOT_DIR}/cmake")
Expand Down
15 changes: 15 additions & 0 deletions cmake/AphCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ if(NOT ipo_supported)
message(WARNING "IPO/LTO not supported: <${error}>")
endif()

if (APH_ENABLE_TSAN)
add_compile_options(-fsanitize=thread)
add_link_options(-fsanitize=thread)
endif()
if (APH_ENABLE_ASAN)
add_compile_options(-fsanitize=thread)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
if (APH_ENABLE_MSAN)
add_compile_options(-fsanitize=thread)
add_compile_options(-fsanitize=memory)
add_link_options(-fsanitize=memory)
endif()

# find linker
find_program(GOLD_LINKER gold)
find_program(MOLD_LINKER mold)
Expand Down

0 comments on commit 693be15

Please sign in to comment.