mk: add 'SANITIZE_UNDEFINED' option

'SANITIZE_UNDEFINED = yes' in 'target.mk' adds the '-fsanitize=undefined'
compiler flag and links the program with libubsan and libsanitizer_common.

Issue #3072
This commit is contained in:
Christian Prochaska 2018-12-06 00:52:22 +01:00 committed by Norman Feske
parent c2884a6e63
commit 5569d2ddc2
2 changed files with 14 additions and 0 deletions

View File

@ -23,6 +23,13 @@ ifeq ($(COVERAGE),yes)
LIBS += libgcov
endif
#
# Add libraries for undefined behavior sanitizer if requested
#
ifeq ($(SANITIZE_UNDEFINED),yes)
LIBS += libubsan libsanitizer_common
endif
#
# Include lib-import description files
#

View File

@ -119,6 +119,13 @@ endif
CC_OPT += -fprofile-arcs -ftest-coverage -fprofile-dir=$(PROFILE_DIR)
endif
#
# Enable the undefined behavior sanitizer if requested
#
ifeq ($(SANITIZE_UNDEFINED),yes)
CC_OPT += -fsanitize=undefined
endif
#
# Default optimization and warning levels
#