From 868809bb5d2ac68e42ffc6965a5b80354a9250b7 Mon Sep 17 00:00:00 2001 From: DepressedTWM Date: Tue, 28 Jul 2026 22:02:38 +0400 Subject: [PATCH] Sanitizers --- CMakeLists.txt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0865f27..be503d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ include(FindPackageHandleStandardArgs) # Options option(STEAM "Build for Steam" OFF) option(DEBUG "Debug mode" OFF) +option(SANITIZERS "Enable sanitizers" OFF) option(NATIVE "Use native instructions(for local use only)" OFF) #x86, arm64, ia-64 option(CPU_ARCH "Enter here your target arch" "x86") @@ -310,12 +311,23 @@ source_group("Binding Source" FILES ${BINDING_SOURCE} ${BINDING_HEADERS}) if (MSVC) list(APPEND DEFINES _CRT_SECURE_NO_WARNINGS NOMINMAX ) if(DEBUG) - add_compile_options(/EHr /fsanitize /validate-charset /DEBUG /RTCu /RTCs /RTCc) + add_compile_options(/EHr /validate-charset /DEBUG /RTCu /RTCs /RTCc) else() add_compile_options(/O2 /fp:fast /GL /GF /GA /Gy) add_link_options(/LTCG /OPT:REF /OPT:ICF) endif() + if(SANITIZERS) + add_compile_options(/fsanitize=address /fsanitize=fuzzer /fsanitize-address-use-after-return) + endif() else() + if(NATIVE) + + endif() + if(SANITIZERS) + set(SANITIZERS "address,undefined,leak,shift,shift-base,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,signed-integer-overflow,bounds,bounds-strict,alignment,object-size,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin,pointer-subtract,pointer-compare") + add_compile_options(-fsanitize=${SANITIZERS}) + add_link_options(-fsanitize=${SANITIZERS}) + endif() if(DEBUG) add_compile_options(-g3 -fno-omit-frame-pointer) else() @@ -370,8 +382,6 @@ else() endif() endif() -############### - if(ANDROID) add_library(main SHARED ${MAIN_HEADERS}