Skip to content

Commit

Permalink
Enable sanitizers for GCC too
Browse files Browse the repository at this point in the history
  • Loading branch information
snej committed Sep 14, 2024
1 parent fa9dad4 commit e49cc56
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cmake/platform_unix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,32 @@ function(setup_litecore_build_unix)
endif()


if (LITECORE_SANITIZE AND NOT CODE_COVERAGE_ENABLED AND (CMAKE_CXX_COMPILER_ID MATCHES Clang))
if (LITECORE_SANITIZE AND NOT CODE_COVERAGE_ENABLED AND (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"))
set(LITECORE_COMPILE_OPTIONS
-fstack-protector
-fsanitize=address
-fsanitize-address-use-after-return=always
-fsanitize-address-use-after-scope
-fsanitize=undefined
-fsanitize=nullability
-fno-sanitize-recover=all # Always exit after UBSan warning
# Note: _FORTIFY_SOURCE is incompatible with ASan; defining it will cause build errors
)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(LITECORE_COMPILE_OPTIONS
${LITECORE_COMPILE_OPTIONS}
-fsanitize=nullability
-fsanitize-address-use-after-return=always
)
endif ()
foreach(target LiteCore CppTests C4Tests)
target_link_options(${target} PRIVATE
-fsanitize=address
-fsanitize=undefined
)
# if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# target_link_options(${target} PRIVATE
# -static-libasan
# )
# endif ()
endforeach ()
else()
set(LITECORE_COMPILE_OPTIONS
Expand Down Expand Up @@ -105,7 +115,7 @@ function(setup_litecore_build_unix)
)

if(LITECORE_WARNINGS_HARDCORE)
if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(LITECORE_CXX_WARNINGS
-Werror
-Weverything # "WARN ALL THE THINGS!!!"
Expand Down

0 comments on commit e49cc56

Please sign in to comment.