From 48f409c1d6d9a8420db08eb8ece764999aeeec48 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Thu, 23 Jan 2020 19:43:15 -0800 Subject: build-options: add SANITIZERS build type Add SANITIZERS build type for using AddressSanitizers to find various memory corruptions within applications. Bug-AGL: SPEC-3040 Change-Id: If430177cbac452c09d710a885cbe802419f13e6b Signed-off-by: Matt Ranostay --- src/cmake/cmake.d/01-build_options.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/cmake/cmake.d/01-build_options.cmake b/src/cmake/cmake.d/01-build_options.cmake index 3b1eca7..2581d6d 100644 --- a/src/cmake/cmake.d/01-build_options.cmake +++ b/src/cmake/cmake.d/01-build_options.cmake @@ -104,6 +104,12 @@ set(COVERAGE_COMPILE_OPTIONS -O0 --coverage CACHE STRING "Compilation flags for COVERAGE build type.") +set(SANITIZERS_COMPILE_OPTIONS + -g + -O0 + -fsanitize=address + -fno-omit-frame-pointer + CACHE STRING "Compilation flags for SANITIZERS build type.") set(RELEASE_COMPILE_OPTIONS -O2 -D_FORTIFY_SOURCE=2 @@ -118,6 +124,9 @@ endforeach() foreach(option ${COVERAGE_COMPILE_OPTIONS}) add_compile_options($<$:${option}>) endforeach() +foreach(option ${SANITIZERS_COMPILE_OPTIONS}) + add_compile_options($<$:${option}>) +endforeach() foreach(option ${RELEASE_COMPILE_OPTIONS}) add_compile_options($<$:${option}>) endforeach() @@ -144,6 +153,9 @@ ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG AND USE_EFENCE) IF(${CMAKE_BUILD_TYPE} MATCHES COVERAGE) list (APPEND link_libraries -coverage) ENDIF(${CMAKE_BUILD_TYPE} MATCHES COVERAGE) +IF(${CMAKE_BUILD_TYPE} MATCHES SANITIZERS) + list (APPEND link_libraries -fsanitize=address) +ENDIF(${CMAKE_BUILD_TYPE} MATCHES SANITIZERS) # set default include directories INCLUDE_DIRECTORIES(${EXTRA_INCLUDE_DIRS}) -- cgit 1.2.3-korg