Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit d22a035

Browse files
committed
Enable sanitizers in root CMakeLists.txt
1 parent 0cfe36a commit d22a035

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

CMakeLists.txt

+31-30
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,37 @@ if(ENABLE_L0)
321321
list(PREPEND llvm_libs PkgConfig::LLVMSPIRVLib)
322322
endif()
323323

324+
# address and thread sanitizer
325+
option(ENABLE_STANDALONE_CALCITE "Require standalone Calcite server" OFF)
326+
option(ENABLE_ASAN "Enable address sanitizer" OFF)
327+
option(ENABLE_TSAN "Enable thread sanitizer" OFF)
328+
option(ENABLE_UBSAN "Enable undefined behavior sanitizer" OFF)
329+
if(ENABLE_ASAN)
330+
set(SAN_FLAGS "-fsanitize=address -O1 -fno-omit-frame-pointer")
331+
add_definitions("-DWITH_DECODERS_BOUNDS_CHECKING")
332+
elseif(ENABLE_TSAN)
333+
add_definitions("-DHAVE_TSAN")
334+
# Copy the config directory to the build dir for TSAN suppressions
335+
file(COPY config DESTINATION ${CMAKE_BINARY_DIR})
336+
337+
set(SAN_FLAGS "-fsanitize=thread -fPIC -O1 -fno-omit-frame-pointer")
338+
# required for older GCC, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64354
339+
add_definitions("-D__SANITIZE_THREAD__")
340+
elseif(ENABLE_UBSAN)
341+
set(SAN_FLAGS "-fsanitize=undefined -fPIC -O1 -fno-omit-frame-pointer")
342+
endif()
343+
if(ENABLE_ASAN OR ENABLE_TSAN OR ENABLE_UBSAN)
344+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS}")
345+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SAN_FLAGS}")
346+
set(ENABLE_STANDALONE_CALCITE ON)
347+
endif()
348+
349+
option(ENABLE_DECODERS_BOUNDS_CHECKING "Enable bounds checking for column decoding" OFF)
350+
351+
if(ENABLE_STANDALONE_CALCITE)
352+
add_definitions("-DSTANDALONE_CALCITE")
353+
endif()
354+
324355
# OmniSciDB submodule
325356
include_directories(${CMAKE_SOURCE_DIR}/omniscidb)
326357

@@ -392,36 +423,6 @@ add_custom_target(hdk_python_clean
392423
add_dependencies(clean-all hdk_python_clean)
393424
add_dependencies(clean-all calcite_java_clean)
394425

395-
# address and thread sanitizer
396-
option(ENABLE_STANDALONE_CALCITE "Require standalone Calcite server" OFF)
397-
option(ENABLE_ASAN "Enable address sanitizer" OFF)
398-
option(ENABLE_TSAN "Enable thread sanitizer" OFF)
399-
option(ENABLE_UBSAN "Enable undefined behavior sanitizer" OFF)
400-
if(ENABLE_ASAN)
401-
set(SAN_FLAGS "-fsanitize=address -O1 -fno-omit-frame-pointer")
402-
add_definitions("-DWITH_DECODERS_BOUNDS_CHECKING")
403-
elseif(ENABLE_TSAN)
404-
add_definitions("-DHAVE_TSAN")
405-
# Copy the config directory to the build dir for TSAN suppressions
406-
file(COPY config DESTINATION ${CMAKE_BINARY_DIR})
407-
408-
set(SAN_FLAGS "-fsanitize=thread -fPIC -O1 -fno-omit-frame-pointer")
409-
# required for older GCC, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64354
410-
add_definitions("-D__SANITIZE_THREAD__")
411-
elseif(ENABLE_UBSAN)
412-
set(SAN_FLAGS "-fsanitize=undefined -fPIC -O1 -fno-omit-frame-pointer")
413-
endif()
414-
if(ENABLE_ASAN OR ENABLE_TSAN OR ENABLE_UBSAN)
415-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS}")
416-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SAN_FLAGS}")
417-
set(ENABLE_STANDALONE_CALCITE ON)
418-
endif()
419-
420-
option(ENABLE_DECODERS_BOUNDS_CHECKING "Enable bounds checking for column decoding" OFF)
421-
422-
if(ENABLE_STANDALONE_CALCITE)
423-
add_definitions("-DSTANDALONE_CALCITE")
424-
endif()
425426

426427
option(ENABLE_TESTS "Build unit tests" ON)
427428
if (ENABLE_TESTS)

0 commit comments

Comments
 (0)