diff options
author | jackpoz <giacomopoz@gmail.com> | 2019-10-19 16:58:45 +0200 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2019-10-19 20:12:48 +0200 |
commit | 580f40769c6c446284dd1f5738f67fb3ee802956 (patch) | |
tree | e311dccaa4a8f39d18235dec28cc4de1683e1c8a /cmake/compiler/gcc | |
parent | 50307d9222596ca81884a35ac5ad95638978fb3f (diff) |
Build/Misc: Add ASan CMake flag
Allow to enable/disable Address Sanitizer in Clang and GCC from CMake flag "ASAN" of type Boolean. It can be enabled passing -DASAN=TRUE to CMake.
Diffstat (limited to 'cmake/compiler/gcc')
-rw-r--r-- | cmake/compiler/gcc/settings.cmake | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cmake/compiler/gcc/settings.cmake b/cmake/compiler/gcc/settings.cmake index 9139a028f18..b2d427ecbeb 100644 --- a/cmake/compiler/gcc/settings.cmake +++ b/cmake/compiler/gcc/settings.cmake @@ -44,6 +44,24 @@ if( WITH_COREDEBUG ) message(STATUS "GCC: Debug-flags set (-g3)") endif() +if(ASAN) + target_compile_options(trinity-compile-option-interface + INTERFACE + -fno-omit-frame-pointer + -fsanitize=address + -fsanitize-recover=address + -fsanitize-address-use-after-scope) + + target_link_options(trinity-compile-option-interface + INTERFACE + -fno-omit-frame-pointer + -fsanitize=address + -fsanitize-recover=address + -fsanitize-address-use-after-scope) + + message(STATUS "GCC: Enabled Address Sanitizer") +endif() + if (BUILD_SHARED_LIBS) target_compile_options(trinity-compile-option-interface INTERFACE |