diff --git a/README.md b/README.md index 0d26b1020..f1cfb8c96 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Or on windows, ### CMake Options * -DCMAKE_CLANG_TIDY=/path/to/clang-tidy (or just clang-tidy or clang-tidy-7.0 if it is in your PATH) - Runs clang-tidy as part of your build. * -DENABLE_SANITIZERS=ON - Enables gcc/clang sanitizers, by default this adds -fsanitizer=address,undefined to the compile flags for projects that call aws_add_sanitizers. +* -DENABLE_SANITIZER_RECOVERY=ON - Enables sanitizer error recovery for projects with known sanitizer issues. Error recovery mode is disabled by default. * -DENABLE_FUZZ_TESTS=ON - Includes fuzz tests in the unit test suite. Off by default, because fuzz tests can take a long time. Set -DFUZZ_TESTS_MAX_TIME=N to determine how long to run each fuzz test (default 60s). * -DCMAKE_INSTALL_PREFIX=/path/to/install - Standard way of installing to a user defined path. If specified when configuring aws-c-common, ensure the same prefix is specified when configuring other aws-c-* SDKs. * -DAWS_STATIC_MSVC_RUNTIME_LIBRARY=ON - Windows-only. Turn ON to use the statically-linked MSVC runtime lib, instead of the DLL. diff --git a/cmake/AwsSanitizers.cmake b/cmake/AwsSanitizers.cmake index 54202006e..3856b7f3a 100644 --- a/cmake/AwsSanitizers.cmake +++ b/cmake/AwsSanitizers.cmake @@ -4,6 +4,7 @@ include(CheckCCompilerFlag) option(ENABLE_SANITIZERS "Enable sanitizers in debug builds" OFF) +option(ENABLE_SANITIZER_RECOVERY "Enable sanitizer recovery mode" OFF) set(SANITIZERS "address;undefined" CACHE STRING "List of sanitizers to build with") # This function checks if a sanitizer is available @@ -70,6 +71,15 @@ function(aws_add_sanitizers target) target_compile_options(${target} PRIVATE -fno-omit-frame-pointer -fsanitize=${PRESENT_SANITIZERS}) target_link_libraries(${target} PUBLIC "-fno-omit-frame-pointer -fsanitize=${PRESENT_SANITIZERS}") + if(NOT ENABLE_SANITIZER_RECOVERY) + # Disable error recovery mode for sanitizers when the compiler supports it. + set(sanitizer_flag "-fno-sanitize-recover=all") + check_c_compiler_flag(${sanitizer_flag} HAS_NO_SANITIZE_RECOVER_ALL) + if(HAS_NO_SANITIZE_RECOVER_ALL) + target_compile_options(${target} PRIVATE ${sanitizer_flag}) + endif() + endif() + string(REPLACE "," ";" PRESENT_SANITIZERS "${PRESENT_SANITIZERS}") set(${target}_SANITIZERS ${PRESENT_SANITIZERS} PARENT_SCOPE) endif()