Skip to content

Commit

Permalink
Merge pull request #5117 from kimden/add-usan
Browse files Browse the repository at this point in the history
Add an option for -fsanitize=undefined
  • Loading branch information
CodingJellyfish authored Jun 25, 2024
2 parents 84dff44 + f0af5ed commit 319d0fc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 319d0fc

Please sign in to comment.