common.mk: add ASAN flag for AddressSanitizer

See https://github.com/google/sanitizers/wiki for details.
Compile with “make ASAN=1” to enable.
This commit is contained in:
Michael Stapelberg 2016-01-09 17:15:33 +01:00
parent 9b4efdc194
commit 5a36d090c7
1 changed files with 6 additions and 0 deletions

View File

@ -1,5 +1,6 @@
UNAME=$(shell uname)
DEBUG=1
ASAN=0
INSTALL=install
LN=ln
PKG_CONFIG=pkg-config
@ -42,6 +43,11 @@ else
CFLAGS ?= -pipe -O2 -freorder-blocks-and-partition
endif
ifeq ($(ASAN),1)
CFLAGS += -fsanitize=address -DI3_ASAN_ENABLED
LDFLAGS += -fsanitize=address
endif
# Default LDFLAGS that users should be able to override
LDFLAGS ?= $(as_needed_LDFLAG)