cmake: toolchain abstraction for undefined behaviour sanitizer

Added toolchain abstraction for undefined behaviour sanitizer

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
This commit is contained in:
Jan Van Winkel 2019-10-04 00:54:00 +02:00 committed by Alberto Escolar
commit 23a866b828
4 changed files with 32 additions and 4 deletions

View file

@ -27,6 +27,10 @@ if (CONFIG_ASAN)
toolchain_cc_asan()
endif ()
if (CONFIG_UBSAN)
toolchain_cc_ubsan()
endif ()
zephyr_compile_definitions(_POSIX_C_SOURCE=200809 _XOPEN_SOURCE=600 _XOPEN_SOURCE_EXTENDED)
zephyr_ld_options(

View file

@ -6,3 +6,10 @@ zephyr_compile_options(-fsanitize=address)
zephyr_ld_options(-fsanitize=address)
endmacro()
macro(toolchain_cc_ubsan)
zephyr_compile_options(-fsanitize=undefined)
zephyr_ld_options(-fsanitize=undefined)
endmacro()

View file

@ -7,3 +7,10 @@ zephyr_link_libraries(-lasan)
zephyr_ld_options(-fsanitize=address)
endmacro()
macro(toolchain_cc_ubsan)
zephyr_compile_options(-fsanitize=undefined)
zephyr_ld_options(-fsanitize=undefined)
endmacro()

View file

@ -45,14 +45,24 @@ config TRACING
help
Enable system tracing. This requires a backend such as SEGGER
Systemview to be enabled as well.
config ASAN
bool "Build with address sanitizer"
depends on ARCH_POSIX
help
Builds Zephyr with Address Sanitizer enabled. This is currently
only supported by the native_posix port, and requires a recent-ish
compiler with the ``-fsanitize=address`` command line option, and
the libasan library.
Builds Zephyr with Address Sanitizer enabled. This is currently
only supported by boards based on the posix architecture, and requires a
recent-ish compiler with the ``-fsanitize=address`` command line option,
and the libasan library.
config UBSAN
bool "Build with undefined behavior sanitizer"
depends on ARCH_POSIX
help
Builds Zephyr with Undefined Behavior Sanitizer enabled.
This is currently only supported by boards based on the posix
architecture, and requires a recent-ish compiler with the
``-fsanitize=undefined`` command line option.
config STACK_USAGE
bool "Generate stack usage information"