summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2020-01-23 19:43:15 -0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2020-01-27 16:58:07 -0800
commitd75b9e1c18ea00d57876b5bc83a6c1fd51cd9571 (patch)
tree0b5c77869679f6f8b4b9189c5c622644bea93183
parent3dbbb816d70f9a006f95cada888d5c522f226f86 (diff)
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 <matt.ranostay@konsulko.com>
-rw-r--r--src/cmake/cmake.d/01-build_options.cmake12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cmake/cmake.d/01-build_options.cmake b/src/cmake/cmake.d/01-build_options.cmake
index bbbd280..9b93d80 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($<$<CONFIG:COVERAGE>:${option}>)
endforeach()
+foreach(option ${SANITIZERS_COMPILE_OPTIONS})
+ add_compile_options($<$<CONFIG:SANITIZERS>:${option}>)
+endforeach()
foreach(option ${RELEASE_COMPILE_OPTIONS})
add_compile_options($<$<CONFIG:RELEASE>:${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})