diff --git a/CHANGELOG.md b/CHANGELOG.md index c28188157814..3ee987d30667 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Current develop ### Added (new features/APIs/variables/...) +- [[PR 1106]](https://github.com/parthenon-hpc-lab/parthenon/pull/1106) Add CMake options for turning on ASAN and HWASAN - [[PR 1100]](https://github.com/parthenon-hpc-lab/parthenon/pull/1100) Custom refinement ops propagated to fluxes - [[PR 1090]](https://github.com/parthenon-hpc-lab/parthenon/pull/1090) SMR with swarms - [[PR 1079]](https://github.com/parthenon-hpc-lab/parthenon/pull/1079) Address XDMF/Visit Issues diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f14e3deb72a..75528f03baf8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,8 @@ option(CHECK_REGISTRY_PRESSURE "Check the registry pressure for Kokkos CUDA kern option(TEST_INTEL_OPTIMIZATION "Test intel optimization and vectorization" OFF) option(TEST_ERROR_CHECKING "Enables the error checking unit test. This test will FAIL" OFF) option(CODE_COVERAGE "Enable code coverage reporting" OFF) +option(ENABLE_ASAN "Turn on ASAN" OFF) +option(ENABLE_HWASAN "Turn on HWASAN (currently ARM-only)" OFF) include(cmake/Format.cmake) include(cmake/Lint.cmake) @@ -290,7 +292,19 @@ if (Kokkos_ENABLE_CUDA AND "${PARTHENON_ENABLE_GPU_MPI_CHECKS}" ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CTestCustom.cmake.in ${CMAKE_BINARY_DIR}/CTestCustom.cmake @ONLY) endif() - +# option to turn on AddressSanitizer for debugging +if(ENABLE_ASAN) + message(STATUS "Compiling with AddressSanitizer and UndefinedBehaviorSanitizer *enabled*") + add_compile_options(-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment) + add_link_options(-fsanitize=address -fsanitize=undefined) +endif(ENABLE_ASAN) + +# option to turn on HWAddressSanitizer for debugging +if(ENABLE_HWASAN) + message(STATUS "Compiling with HWAddressSanitizer *enabled*") + add_compile_options(-fsanitize=hwaddress) + add_link_options(-fsanitize=hwaddress) +endif(ENABLE_HWASAN) # Build Tests and download Catch2