From 58fe0f9e4acb4cdc83ea70e368d648abe457d54e Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sat, 19 Oct 2019 16:58:45 +0200 Subject: 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. (cherry picked from commit 580f40769c6c446284dd1f5738f67fb3ee802956) --- cmake/compiler/gcc/settings.cmake | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'cmake/compiler/gcc') diff --git a/cmake/compiler/gcc/settings.cmake b/cmake/compiler/gcc/settings.cmake index f5a249bfba0..abf9fa5acf7 100644 --- a/cmake/compiler/gcc/settings.cmake +++ b/cmake/compiler/gcc/settings.cmake @@ -48,6 +48,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 -- cgit v1.2.3