mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 03:02:30 +00:00
feat(build): enable UBsan by default when using GCC and Clang
This commit is contained in:
parent
b5902f5230
commit
d9b4b75236
1 changed files with 13 additions and 2 deletions
|
|
@ -28,9 +28,20 @@ set(CMAKE_BUILD_TYPE Debug)
|
||||||
|
|
||||||
include(lib/system/cmake/system.cmake)
|
include(lib/system/cmake/system.cmake)
|
||||||
|
|
||||||
# Some templates abuse offsetof
|
# Compiler options
|
||||||
if(WHOA_SYSTEM_LINUX OR WHOA_SYSTEM_MAC)
|
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")
|
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()
|
endif()
|
||||||
|
|
||||||
# OS defines
|
# OS defines
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue