mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-04-18 19:12:44 +03:00
feat(build): enable UBsan by default when using GCC and Clang
This commit is contained in:
parent
b5902f5230
commit
d9b4b75236
@ -28,9 +28,20 @@ set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
include(lib/system/cmake/system.cmake)
|
||||
|
||||
# Some templates abuse offsetof
|
||||
if(WHOA_SYSTEM_LINUX OR WHOA_SYSTEM_MAC)
|
||||
# Compiler options
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" or CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
# Some templates abuse offsetof
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof")
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT DEFINED WHOA_ALLOW_UNDEFINED_BEHAVIOR)
|
||||
# Enable UBsan
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
|
||||
# Allow strange alignments
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=alignment")
|
||||
else()
|
||||
# Disable UBsan completely
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=undefined")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# OS defines
|
||||
|
Loading…
Reference in New Issue
Block a user