From aadb85d627d9b7aef8c990a147a61a85d4ea7f49 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Sun, 16 Nov 2025 06:44:41 -0600 Subject: [PATCH] chore(build): enable ASan for gcc debug builds --- CMakeLists.txt | 4 ++++ test/CMakeLists.txt | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 729a07c..d2d2609 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,10 @@ if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL "Debug") LCOV_ARGS --rc branch_coverage=1 GENHTML_ARGS --rc genhtml_branch_coverage=1 ) + + # Enable ASan for debug builds on gcc + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer") endif() if(WHOA_TEST_STORMDLL) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0ae0b45..ef3a1ff 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -53,7 +53,13 @@ target_include_directories(StormTest if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL "Debug") include(CodeCoverage) + target_compile_options(${PROJECT_NAME} PRIVATE -g -fprofile-arcs -ftest-coverage -O0) + + # Enable ASan for debug builds on gcc + target_link_options(StormTest + PUBLIC -fsanitize=address + ) endif() install(TARGETS StormTest DESTINATION "bin")