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

View File

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