Skip to content

Commit 4c831ff

Browse files
authored
Revise SVS_CHECK_BOUNDS logic (#301)
- Refactors `SVS_CHECK_BOUNDS` logic so that explicitly passing `SVS_EXPERIMENTAL_CHECK_BOUNDS` will trump any other settings, but not explicitly passing will lead to `SVS_CHECK_BOUNDS` depending on `CMAKE_BUILD_TYPE` - Previously, non-Release builds would force bounds checking on even when a user explicitly passed -`DSVS_EXPERIMENTAL_CHECK_BOUNDS=OFF`, but this now changes - see table below for more details - Updates docs to reflect the conditional default SVS_CHECK_BOUNDS value (current behavior) <img width="599" height="72" alt="image" src="https://github.com/user-attachments/assets/1ec5cce8-4dee-47c0-95d5-35619a91a1b3" /> SVS_CHECK_BOUNDS value (updated behavior) <img width="599" height="73" alt="image" src="https://github.com/user-attachments/assets/f05e0bf6-c083-49b8-acdc-4eea9e272cc1" />
1 parent 1a33e4e commit 4c831ff

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

cmake/options.cmake

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,18 @@ option(SVS_EXPERIMENTAL_CLANG_TIDY
8282
OFF # disabled by default
8383
)
8484

85-
option(SVS_EXPERIMENTAL_CHECK_BOUNDS
86-
"Enable bounds checking on many data accesses."
87-
OFF # diabled by default
88-
)
85+
# If not explicitly set by user, check bounds for non-release builds
86+
if (CMAKE_BUILD_TYPE STREQUAL "Release")
87+
option(SVS_EXPERIMENTAL_CHECK_BOUNDS
88+
"Enable bounds checking on many data accesses."
89+
OFF
90+
)
91+
else()
92+
option(SVS_EXPERIMENTAL_CHECK_BOUNDS
93+
"Enable bounds checking on many data accesses."
94+
ON
95+
)
96+
endif()
8997

9098
option(SVS_EXPERIMENTAL_ENABLE_NUMA
9199
"Enable NUMA aware data structures. (Experimental)"
@@ -126,8 +134,7 @@ if (SVS_NO_AVX512)
126134
target_compile_options(${SVS_LIB} INTERFACE -mno-avx512f)
127135
endif()
128136

129-
# Enable bounds-checking by default for non-release builds.
130-
if (SVS_EXPERIMENTAL_CHECK_BOUNDS OR NOT CMAKE_BUILD_TYPE STREQUAL "Release")
137+
if (SVS_EXPERIMENTAL_CHECK_BOUNDS)
131138
target_compile_definitions(${SVS_LIB} INTERFACE -DSVS_CHECK_BOUNDS=1)
132139
else()
133140
target_compile_definitions(${SVS_LIB} INTERFACE -DSVS_CHECK_BOUNDS=0)

0 commit comments

Comments
 (0)