diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-06-21 08:39:30 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-06-28 07:06:46 -0700 |
commit | 6c6888037c8d82228b480eeba0eaf1b0aa83e9f8 (patch) | |
tree | 5ccd44915959fa98d811bb4e53f71b295ec41317 /Makefile.toolchain | |
parent | dcfbe0be69d3445edfd45fb036bfae2581b6fdd5 (diff) | |
download | chrome-ec-6c6888037c8d82228b480eeba0eaf1b0aa83e9f8.tar.gz |
ec: Make it possible to run tests with AddressSanitizer enabled
Automatically use CC=clang if TEST_ASAN is specified.
Also, add a __no_sanitize_address attribute macro to prevent ASan
from adding guards around host_command, mkbp_event, and hook
"arrays" that are generated at link-time.
Also, set ASAN_OPTIONS env variable in run_host_test.
BRANCH=none
BUG=chromium:854924
TEST=make TEST_ASAN=y runtests -j
Change-Id: Iaf0ec405022760d757a8a9d62a5022460d1b16e1
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1109661
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'Makefile.toolchain')
-rw-r--r-- | Makefile.toolchain | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Makefile.toolchain b/Makefile.toolchain index e0f796fae6..c0ecdc91ca 100644 --- a/Makefile.toolchain +++ b/Makefile.toolchain @@ -15,6 +15,11 @@ ifeq ($(make_version_ok),) $(error ERROR: GNU make version $(min_make_version) or higher required.) endif +# Default to clang if TEST_ASAN is enabled +ifneq ($(TEST_ASAN),) +CC=clang +endif + # Extract cc-name cc-name:=$(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) @@ -54,7 +59,8 @@ CFLAGS_TEST=$(if $(TEST_BUILD),-DTEST_BUILD \ $(if $(CTS_MODULE), $(CFLAGS_CTS)) \ $(if $(EMU_BUILD),-DEMU_BUILD) \ $(if $($(PROJECT)-scale),-DTEST_TIME_SCALE=$($(PROJECT)-scale)) \ - -DTEST_$(PROJECT) -DTEST_$(UC_PROJECT) + -DTEST_$(PROJECT) -DTEST_$(UC_PROJECT) \ + $(if $(TEST_ASAN),-fsanitize=address) CFLAGS_COVERAGE=$(if $(TEST_COVERAGE),-fprofile-arcs -ftest-coverage \ -DTEST_COVERAGE,) CFLAGS_DEFINE=-DOUTDIR=$(out)/$(BLD) -DCHIP=$(CHIP) -DBOARD_TASKFILE=$(_tsk_lst_file) \ @@ -101,7 +107,8 @@ LDFLAGS=-nostdlib -g -Wl,-X -Wl,--gc-sections -Wl,--build-id=none \ $(LDFLAGS_EXTRA) $(CFLAGS_CPU) BUILD_LDFLAGS=$(LIBFTDI_LDLIBS) HOST_TEST_LDFLAGS=-Wl,-T core/host/host_exe.lds -lrt -pthread -rdynamic -lm\ - $(if $(TEST_COVERAGE),-fprofile-arcs,) + $(if $(TEST_COVERAGE),-fprofile-arcs,) \ + $(if $(TEST_ASAN), -fsanitize=address) # utility function to provide overridable defaults # $1: name of variable to set |