CMake: Add proper sanitizer options for Swift files

Apparently UBSAN + Swift doesn't work on Linux :<
This commit is contained in:
Andrew Kaster 2024-07-24 20:09:05 -06:00
parent 07d387af96
commit 7afe183172
Notes: github-actions[bot] 2024-07-31 00:39:08 +00:00
2 changed files with 11 additions and 9 deletions

View file

@ -43,13 +43,10 @@ endif()
if (ENABLE_MEMORY_SANITIZER)
add_cxx_compile_options(-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer)
add_cxx_link_options(-fsanitize=memory -fsanitize-memory-track-origins)
add_swift_compile_options(-sanitize=memory)
add_swift_link_options(-sanitize=memory)
endif()
if (ENABLE_UNDEFINED_SANITIZER)
if (ENABLE_UNDEFINED_SANITIZER AND (APPLE OR NOT ENABLE_SWIFT))
add_cxx_compile_options(-fsanitize=undefined -fno-omit-frame-pointer)
add_swift_compile_options(-sanitize=address)
if (UNDEFINED_BEHAVIOR_IS_FATAL)
add_cxx_compile_options(-fno-sanitize-recover=undefined)
endif()
@ -57,7 +54,8 @@ if (ENABLE_UNDEFINED_SANITIZER)
add_cxx_compile_options(-fno-sanitize=function)
endif()
add_cxx_link_options(-fsanitize=undefined)
add_swift_link_options(-sanitize=address)
add_swift_compile_options(-sanitize=undefined)
add_swift_link_options(-sanitize=undefined)
endif()
if (HAIKU)

View file

@ -94,15 +94,17 @@ endif()
if (ENABLE_ADDRESS_SANITIZER)
add_cxx_compile_options(-fsanitize=address -fno-omit-frame-pointer)
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=address")
add_cxx_link_options(-fsanitize=address)
add_swift_compile_options(-sanitize=address)
add_swift_link_options(-sanitize=address)
endif()
if (ENABLE_MEMORY_SANITIZER)
add_cxx_compile_options(-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer)
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins")
add_cxx_link_options(-fsanitize=memory -fsanitize-memory-track-origins)
endif()
if (ENABLE_UNDEFINED_SANITIZER)
if (ENABLE_UNDEFINED_SANITIZER AND (APPLE OR NOT ENABLE_SWIFT))
add_cxx_compile_options(-fsanitize=undefined -fno-omit-frame-pointer)
if (UNDEFINED_BEHAVIOR_IS_FATAL)
add_cxx_compile_options(-fno-sanitize-recover=undefined)
@ -110,7 +112,9 @@ if (ENABLE_UNDEFINED_SANITIZER)
if (APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang$" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "17")
add_cxx_compile_options(-fno-sanitize=function)
endif()
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=undefined")
add_cxx_link_options(-fsanitize=undefined)
add_swift_compile_options(-sanitize=undefined)
add_swift_link_options(-sanitize=undefined)
endif()
if (ENABLE_COMPILETIME_FORMAT_CHECK)