Merge branch 'jk/build-with-asan'
authorJunio C Hamano <gitster@pobox.com>
Thu, 20 Jul 2017 23:29:59 +0000 (16:29 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Jul 2017 23:29:59 +0000 (16:29 -0700)
A recent update made it easier to use "-fsanitize=" option while
compiling but supported only one sanitize option. Allow more than
one to be combined, joined with a comma, like "make SANITIZE=foo,bar".

* jk/build-with-asan:
Makefile: allow combining UBSan with other sanitizers

Makefile
index ba4359ef8dceb294fba6da3037c976d8b9d2cbad..9b98535a044256a8887e579d963809aff46fdc0b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1022,10 +1022,15 @@ ifdef DEVELOPER
 CFLAGS += $(DEVELOPER_CFLAGS)
 endif
 
+comma := ,
+empty :=
+space := $(empty) $(empty)
+
 ifdef SANITIZE
+SANITIZERS := $(foreach flag,$(subst $(comma),$(space),$(SANITIZE)),$(flag))
 BASIC_CFLAGS += -fsanitize=$(SANITIZE) -fno-sanitize-recover=$(SANITIZE)
 BASIC_CFLAGS += -fno-omit-frame-pointer
-ifeq ($(SANITIZE),undefined)
+ifneq ($(filter undefined,$(SANITIZERS)),)
 BASIC_CFLAGS += -DNO_UNALIGNED_LOADS
 endif
 endif