From 1f64e88d342b4db83996eec4e567a47662f60468 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Wed, 14 May 2025 02:40:03 +0200 Subject: [PATCH] Add UBSan (#78) --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3431b61..e0d77706 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ endif() option(ISLE_BUILD_APP "Build isle application" ON) option(ISLE_ASAN "Enable Address Sanitizer" OFF) +option(ISLE_UBSAN "Enable Undefined Behavior Sanitizer" OFF) option(ISLE_WERROR "Treat warnings as errors" OFF) cmake_dependent_option(ISLE_USE_DX5 "Build with internal DirectX 5 SDK" "${NOT_MINGW}" "WIN32;CMAKE_SIZEOF_VOID_P EQUAL 4" OFF) cmake_dependent_option(ISLE_MINIWIN "Use miniwin and minimfc" ON "NOT ISLE_USE_DX5" OFF) @@ -74,6 +75,11 @@ if (ISLE_ASAN) add_link_options(-fsanitize=address) endif() +if (ISLE_UBSAN) + add_compile_options(-fsanitize=undefined -fno-sanitize-recover=undefined) + add_link_options(-fsanitize=undefined) +endif() + #if (NOT WIN32) add_library(miniwin STATIC EXCLUDE_FROM_ALL miniwin/miniwin/src/miniwin.cpp