Skip to content

Commit a3ffb27

Browse files
committed
split UseSanitizer into UseAddressSanitizer and UseUndefinedSanitizer
1 parent 3a58ef8 commit a3ffb27

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ option(BuildJK2SPGame "Whether to create projects for the jk2 sp gamecode mod (j
4848
option(BuildJK2SPRdVanilla "Whether to create projects for the jk2 sp renderer (rdjosp-vanilla_x86.dll)" OFF)
4949

5050
option(BuildTests "Whether to build automatic unit tests (requires Boost)" OFF)
51-
option(UseSanitizer "Whether to enable runtime sanitizers (e.g. AddressSanitizer)" OFF)
51+
option(UseAddressSanitizer "Whether to enable runtime address sanitizer" OFF)
52+
option(UseUndefinedSanitizer "Whether to enable runtime Undefined Behavior sanitizer" OFF)
5253

5354
include(CMakeDependentOption)
5455
cmake_dependent_option(BuildSymbolServer "Build WIP Windows Symbol Server (experimental and unused)" OFF "NOT WIN32 OR NOT MSVC" OFF)
@@ -233,9 +234,14 @@ elseif (("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" M
233234
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
234235
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
235236

236-
if(CMAKE_BUILD_TYPE MATCHES "DEBUG" OR CMAKE_BUILD_TYPE MATCHES "Debug" AND UseSanitizer)
237+
if(UseAddressSanitizer)
238+
# also raise stack size drastically (to 64MiB), since the sanitizer adds overhead to stack frames
237239
add_compile_options(-fsanitize=address)
238-
add_link_options(-fsanitize=address)
240+
add_link_options(-fsanitize=address -z stack-size=4000000)
241+
endif()
242+
if(UseUndefinedSanitizer)
243+
add_compile_options(-fsanitize=undefined)
244+
add_link_options(-fsanitize=undefined)
239245
endif()
240246

241247
# additional flags for debug configuration

0 commit comments

Comments
 (0)