Explorar o código

cmake: enable AddressSanitizer in Debug builds

Christian Rauch %!s(int64=4) %!d(string=hai) anos
pai
achega
f8b4a6e25a
Modificáronse 1 ficheiros con 17 adicións e 0 borrados
  1. 17 0
      CMakeLists.txt

+ 17 - 0
CMakeLists.txt

@@ -2323,6 +2323,23 @@ if(SDL_STATIC)
   endif()
 endif()
 
+set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} \
+    -fsanitize=address \
+    -fsanitize=bool \
+    -fsanitize=bounds \
+    -fsanitize=enum \
+    -fsanitize=float-cast-overflow \
+    -fsanitize=float-divide-by-zero \
+    -fsanitize=nonnull-attribute \
+    -fsanitize=returns-nonnull-attribute \
+    -fsanitize=signed-integer-overflow \
+    -fsanitize=undefined \
+    -fsanitize=vla-bound \
+    -fno-sanitize=alignment \
+    -fsanitize=leak \
+    -fsanitize=object-size \
+")
+
 ##### Tests #####
 
 if(SDL_TEST)