From 6afc1160361de13ac73ed5bfc13d15df15157433 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 11 Mar 2020 11:32:56 +0100 Subject: [PATCH] nvs: enable address sanitizer in host tests when building with clang --- components/nvs_flash/test_nvs_host/Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/nvs_flash/test_nvs_host/Makefile b/components/nvs_flash/test_nvs_host/Makefile index 68c2161f9a..5c20d8f20c 100644 --- a/components/nvs_flash/test_nvs_host/Makefile +++ b/components/nvs_flash/test_nvs_host/Makefile @@ -28,11 +28,23 @@ SOURCE_FILES = \ crc.cpp \ main.cpp +ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) +COMPILER := clang +else +COMPILER := gcc +endif + CPPFLAGS += -I../include -I../src -I./ -I../../esp_common/include -I../../esp32/include -I ../../mbedtls/mbedtls/include -I ../../spi_flash/include -I ../../soc/include -I ../../xtensa/include -I ../../../tools/catch -fprofile-arcs -ftest-coverage CFLAGS += -fprofile-arcs -ftest-coverage CXXFLAGS += -std=c++11 -Wall -Werror LDFLAGS += -lstdc++ -Wall -fprofile-arcs -ftest-coverage +ifeq ($(COMPILER),clang) +CFLAGS += -fsanitize=address +CXXFLAGS += -fsanitize=address +LDFLAGS += -fsanitize=address +endif + OBJ_FILES = $(SOURCE_FILES:.cpp=.o) COVERAGE_FILES = $(OBJ_FILES:.o=.gc*)