Skip to content

Commit 56b5db3

Browse files
peffgitster
authored andcommitted
Makefile: add helper for compiling with -fsanitize
You can already build and test with ASan by doing: make CFLAGS=-fsanitize=address test but there are a few slight annoyances: 1. It's a little long to type. 2. It override your CFLAGS completely. You'd probably still want -O2, for instance. 3. It's a good idea to also turn off "recovery", which lets the program keep running after a problem is detected (with the intention of finding as many bugs as possible in a given run). Since Git's test suite should generally run without triggering any problems, it's better to abort immediately and fail the test when we do find an issue. With this patch, all of that happens automatically when you run: make SANITIZE=address test Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bf1ce90 commit 56b5db3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,10 @@ ifdef DEVELOPER
991991
CFLAGS += $(DEVELOPER_CFLAGS)
992992
endif
993993

994+
ifdef SANITIZE
995+
BASIC_CFLAGS += -fsanitize=$(SANITIZE) -fno-sanitize-recover=$(SANITIZE)
996+
endif
997+
994998
ifndef sysconfdir
995999
ifeq ($(prefix),/usr)
9961000
sysconfdir = /etc

0 commit comments

Comments
 (0)