build: add address santizer, compile with SANITIZE_ADDRESS=1
authorFerry Huberts <ferry.huberts@pelagic.nl>
Sat, 9 Aug 2014 10:13:49 +0000 (12:13 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Sat, 9 Aug 2014 10:40:05 +0000 (12:40 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Makefile
Makefile.inc

index f35a020..516fa5b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -46,7 +46,7 @@ INSTALLOVERWRITE ?=
 include Makefile.inc
 
 # pass generated variables to save time
-MAKECMD = $(MAKE) OS="$(OS)" WARNINGS="$(WARNINGS)" VERBOSE="$(VERBOSE)"
+MAKECMD = $(MAKE) OS="$(OS)" WARNINGS="$(WARNINGS)" VERBOSE="$(VERBOSE)" SANITIZE_ADDRESS="$(SANITIZE_ADDRESS)"
 
 LIBS +=                $(OS_LIB_DYNLOAD)
 ifeq ($(OS), win32)
index dc1122c..9f29f74 100644 (file)
@@ -20,6 +20,8 @@ MUDFLAP ?= 0
 # shows full compiler/linker calls if activated
 VERBOSE ?= 0
 
+SANITIZE_ADDRESS ?= 0
+
 ifeq ($(VERBOSE),0)
 MAKECMDPREFIX = @
 else
@@ -186,6 +188,13 @@ ifneq ($(MUDFLAP),0)
 LIBS +=                -lmudflapth
 endif
 
+ifeq ($(OS),linux)
+  ifneq ($(SANITIZE_ADDRESS),0)
+    CFLAGS  += -fsanitize=address -fno-omit-frame-pointer
+    LDFLAGS += -fsanitize=address -static-libasan
+  endif
+endif
+
 # extra options from the outside
 CPPFLAGS +=    $(EXTRA_CPPFLAGS)