From bf7a23e6301a80d2d5850b22540b2107bb7c83c7 Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Wed, 12 Jun 2024 20:13:09 -0400 Subject: [PATCH 1/2] add CMake options for turning on ASAN and HWASAN Add CMake options to build with AddressSanitizer/HWAddressSanitizer turned on. HWAddressSanitizer only works on ARM platforms due to hardware support but runs faster than AddressSanitizer. --- CMakeLists.txt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 From 862a0ac91b5d8f3c836b0043d98518a218f54e6a Mon Sep 17 00:00:00 2001 From: Ben Wibking Date: Thu, 13 Jun 2024 10:21:12 -0400 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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