@@ -45,6 +45,7 @@ if (LEGACY_BUILD)
4545 option (ANDROID_BUILD_ZLIB "When building for Android, should Zlib be built as well" ON )
4646 option (FORCE_CURL "Forces usage of the Curl client rather than the default OS-specific api" OFF )
4747 option (ENABLE_ADDRESS_SANITIZER "Flags to enable/disable Address Sanitizer for gcc or clang" OFF )
48+ option (ENABLE_UB_SANITIZER "Flags to enable/disable Undefined Behavior Sanitizer for gcc or clang" OFF )
4849 option (BYPASS_DEFAULT_PROXY "Bypass the machine's default proxy settings when using IXmlHttpRequest2" ON )
4950 option (BUILD_DEPS "Build third-party dependencies" ON )
5051 option (USE_OPENSSL "Set this if you want to use your system's OpenSSL 1.0.2/1.1.1 compatible libcrypto" ON )
@@ -241,6 +242,10 @@ if (LEGACY_BUILD)
241242 set (BUILD_SHARED_LIBS OFF )
242243 endif ()
243244 set (CRT_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS} )
245+ if (ENABLE_UB_SANITIZER)
246+ set (ENABLE_SANITIZERS ON CACHE BOOL "Enable sanitizers in dependencies" )
247+ set (SANITIZERS "undefined" CACHE STRING "List of sanitizers to build with" )
248+ endif ()
244249 add_subdirectory (crt/aws-crt-cpp)
245250 set (BUILD_TESTING ${BUILD_TESTING_PREV} )
246251 if (ENABLE_OPENSSL_ENCRYPTION)
@@ -322,6 +327,10 @@ if (LEGACY_BUILD)
322327 endif ()
323328 endif ()
324329
330+ if (ENABLE_UB_SANITIZER)
331+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -g -fno-omit-frame-pointer" )
332+ endif ()
333+
325334 include (CheckCXXSymbolExists)
326335
327336 check_cxx_symbol_exists("pathconf" "unistd.h" HAS_PATHCONF)
0 commit comments