Makefile: allow combining UBSan with other sanitizers
Multiple sanitizers can be specified as a comma-separated list. Set the flag NO_UNALIGNED_LOADS even if UndefinedBehaviorSanitizer is not the only sanitizer to build with. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Jul 15, 2017 at 19:18 UTC
425ca6710b207f36ca0dfd28cc28b5f360355bef
1 file changed
+6
-1
Makefile
+6
-1
@@ -991,10 +991,15 @@ ifdef DEVELOPER
991
CFLAGS += $(DEVELOPER_CFLAGS)
992
endif
993
994
+comma := ,
995
+empty :=
996
+space := $(empty) $(empty)
997
+
998
ifdef SANITIZE
999
+SANITIZERS := $(foreach flag,$(subst $(comma),$(space),$(SANITIZE)),$(flag))
1000
BASIC_CFLAGS += -fsanitize=$(SANITIZE) -fno-sanitize-recover=$(SANITIZE)
1001
BASIC_CFLAGS += -fno-omit-frame-pointer
997
-ifeq ($(SANITIZE),undefined)
1002
+ifneq ($(filter undefined,$(SANITIZERS)),)
1003
BASIC_CFLAGS += -DNO_UNALIGNED_LOADS
1004
endif
1005
endif