Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions cmake/AwsSanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down