From f0af5ed9926d9fc42aaa49d8bc7eb8f1871dadfb Mon Sep 17 00:00:00 2001 From: kimden <23140380+kimden@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:44:48 +0400 Subject: [PATCH] Add an option for -fsanitize=undefined --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d85449a5f..470b0f4ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)