Merge pull request #5117 from kimden/add-usan

Add an option for -fsanitize=undefined
This commit is contained in:
CodingJellyfish 2024-06-25 20:03:43 +08:00 committed by GitHub
commit 319d0fc68c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,6 +111,7 @@ endif()
if(UNIX AND NOT APPLE)
option(USE_ASAN "Build with Leak/Address sanitizer" OFF)
option(USE_TSAN "Build with Thread sanitizer" OFF)
option(USE_USAN "Build with Undefined Behaviour sanitizer" OFF)
option(USE_LIBBFD "Use libbfd for crash reporting and leak check" OFF)
endif()
@ -122,6 +123,10 @@ if(USE_TSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
endif()
if(USE_USAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
endif()
set(STK_SOURCE_DIR "src")
set(STK_DATA_DIR "${PROJECT_SOURCE_DIR}/data")
@ -781,6 +786,9 @@ if(UNIX AND NOT APPLE)
if(USE_TSAN)
target_link_libraries(supertuxkart "-fsanitize=thread")
endif()
if(USE_USAN)
target_link_libraries(supertuxkart "-fsanitize=undefined")
endif()
endif()
if(BUILD_RECORDER)