Skip to content

Commit

Permalink
Provide direct CMake support for clang sanitizer (#6924)
Browse files Browse the repository at this point in the history
Set up a cached CMake variable to enable Clang sanitizer.
  • Loading branch information
ppenzin authored May 3, 2024
1 parent 5f53f55 commit 4b0b554
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ else(NOT CHAKRACORE_BUILD_SH)
unset(LIBS_ONLY_BUILD_SH CACHE)
set(CC_LIBS_ONLY_BUILD 1)
endif()

if (CLANG_SANITIZE_SH)
set(CLANG_SANITIZE ${CLANG_SANITIZE_SH})
unset(CLANG_SANITIZE_SH CACHE)
endif()

endif(NOT CHAKRACORE_BUILD_SH)

if(CC_USES_SYSTEM_ARCH_SH OR NOT CHAKRACORE_BUILD_SH)
Expand Down Expand Up @@ -573,12 +579,11 @@ endif()
include_directories(SYSTEM /usr/local/include)
include(pal/src/configure.cmake)

# this should be after `detect feature` to not to affect feature detection
# Clang -fsanitize.
if (CLANG_SANITIZE_SH)
# Clang sanitizer support, this should be after `detect feature` to not to
# affect feature detection
if (CLANG_SANITIZE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${CLANG_SANITIZE_SH}")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -fsanitize=${CLANG_SANITIZE_SH}")
unset(CLANG_SANITIZE_SH CACHE) # don't cache
endif()

add_subdirectory (pal)
Expand Down

0 comments on commit 4b0b554

Please # to comment.