From b93c6153688b9035a6472836a322c00cf7a45fc4 Mon Sep 17 00:00:00 2001 From: superp00t Date: Mon, 22 Jul 2024 02:05:52 -0400 Subject: [PATCH] fix(build): correctly disable sanitizers in zig build script when WHOA_UB_SAN is false or release mode is not debug --- CMakeLists.txt | 4 +++- build.zig | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43c7ebc..e7a208f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ else() endif() if (WHOA_BUILD_GLSDL) add_definitions(-DWHOA_BUILD_GLSDL) -endif() +endif() # FMOD option(WHOA_BUILD_FMOD "Disable/Enable the use of the FMOD sound API. This introduces a dependency on a proprietary FMOD dynamically linked library." 0) @@ -67,6 +67,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") # Allow strange alignments set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=alignment") + # Make encountering UB an unrecoverable error + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize-recover=all") else() # Disable UBsan completely set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=undefined") diff --git a/build.zig b/build.zig index c7887f7..8665a26 100644 --- a/build.zig +++ b/build.zig @@ -111,9 +111,11 @@ pub fn build(b: *std.Build) void { if (ub_san) { // Disable UBsan alignment checks only whoa_compiler_flags_list.append("-fno-sanitize=alignment") catch {}; + whoa_compiler_flags_list.append("-fno-sanitize=float-cast-overflow") catch {}; + whoa_compiler_flags_list.append("-fno-sanitize=signed-integer-overflow") catch {}; } else { // Disable UBsan - whoa_compiler_flags_list.append("-fsanitize=undefined") catch {}; + whoa_compiler_flags_list.append("-fno-sanitize=all") catch {}; } var build_gll = false;