cmake: toolchain abstraction for address sanitizer

Added toolchain abstraction for address sanitizer

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
This commit is contained in:
Jan Van Winkel 2019-08-22 22:03:22 +02:00 committed by Anas Nashif
commit 89e97d13ec
6 changed files with 21 additions and 3 deletions

View file

@ -24,9 +24,7 @@ if (CONFIG_COVERAGE)
endif ()
if (CONFIG_ASAN)
zephyr_compile_options(-fsanitize=address)
zephyr_link_libraries(-lasan)
zephyr_ld_options(-fsanitize=address)
toolchain_cc_asan()
endif ()
zephyr_compile_definitions(_POSIX_C_SOURCE=200809 _XOPEN_SOURCE=600 _XOPEN_SOURCE_EXTENDED)

View file

@ -86,6 +86,7 @@ include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_warnings.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_imacros.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_base.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_coverage.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_sanitizers.cmake)
macro(toolchain_cc_security_fortify)
# No op, clang doesn't understand fortify at all

View file

@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
macro(toolchain_cc_asan)
zephyr_compile_options(-fsanitize=address)
zephyr_ld_options(-fsanitize=address)
endmacro()

View file

@ -126,3 +126,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_warnings.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_imacros.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_base.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_coverage.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_sanitizers.cmake)

View file

@ -0,0 +1,9 @@
# SPDX-License-Identifier: Apache-2.0
macro(toolchain_cc_asan)
zephyr_compile_options(-fsanitize=address)
zephyr_link_libraries(-lasan)
zephyr_ld_options(-fsanitize=address)
endmacro()

View file

@ -77,3 +77,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_warnings.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_imacros.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_base.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_coverage.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_sanitizers.cmake)