From 830912e28aef9d2234d5bc5b9098f19e56c9cf75 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Wed, 24 May 2017 15:00:54 -0700 Subject: [PATCH] Add thread sanitizer to configure options Change-Id: Ibeab0bc70bb59da4ebb8bd175642f5f549f1d273 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/362425 Reviewed-by: Jim Harris Tested-by: SPDK Automated Test System --- CONFIG | 3 +++ configure | 14 ++++++++++++++ mk/spdk.common.mk | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/CONFIG b/CONFIG index bcb39880e..22d1553b1 100644 --- a/CONFIG +++ b/CONFIG @@ -49,6 +49,9 @@ CONFIG_ASAN?=n # Build with Undefined Behavior Sanitizer enabled CONFIG_UBSAN?=n +# Build with Thread Sanitizer enabled +CONFIG_TSAN?=n + # Directory that contains the desired SPDK environment library. # By default, this is implemented using DPDK. CONFIG_ENV?=$(SPDK_ROOT_DIR)/lib/env_dpdk diff --git a/configure b/configure index d907a2fd6..1b0aad8b3 100755 --- a/configure +++ b/configure @@ -62,6 +62,12 @@ for i in "$@"; do --disable-ubsan) CONFIG_UBSAN=n ;; + --enable-tsan) + CONFIG_TSAN=y + ;; + --disable-tsan) + CONFIG_TSAN=n + ;; --enable-coverage) CONFIG_COVERAGE=y ;; @@ -132,6 +138,11 @@ if [ "$CONFIG_FIO_PLUGIN" = "y" ]; then fi fi +if [ "$CONFIG_ASAN" = "y" -a "$CONFIG_TSAN" = "y" ]; then + echo "ERROR: ASAN and TSAN cannot be enabled at the same time." + exit 1 +fi + echo -n "Creating CONFIG.local..." # Write the configuration file @@ -154,6 +165,9 @@ fi if [ -n "$CONFIG_UBSAN" ]; then echo "CONFIG_UBSAN?=$CONFIG_UBSAN" >> CONFIG.local fi +if [ -n "$CONFIG_TSAN" ]; then + echo "CONFIG_TSAN?=$CONFIG_TSAN" >> CONFIG.local +fi if [ -n "$CONFIG_ENV" ]; then echo "CONFIG_ENV?=$CONFIG_ENV" >> CONFIG.local fi diff --git a/mk/spdk.common.mk b/mk/spdk.common.mk index 479b27dec..207212287 100644 --- a/mk/spdk.common.mk +++ b/mk/spdk.common.mk @@ -115,6 +115,11 @@ COMMON_CFLAGS += -fsanitize=undefined LDFLAGS += -fsanitize=undefined endif +ifeq ($(CONFIG_TSAN),y) +COMMON_CFLAGS += -fsanitize=thread +LDFLAGS += -fsanitize=thread +endif + COMMON_CFLAGS += -pthread LDFLAGS += -pthread