From 346fa4d7f4506e9ddbf8dc8278210bc0c2b08251 Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Thu, 14 Dec 2017 13:27:49 -0800 Subject: [PATCH] Added ZT_SANITIZE option to makefiles. This your new memory debugging best friend --- make-bsd.mk | 4 ++++ make-linux.mk | 4 ++++ make-mac.mk | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/make-bsd.mk b/make-bsd.mk index c3f2f3a1b..713cafc0f 100644 --- a/make-bsd.mk +++ b/make-bsd.mk @@ -7,6 +7,10 @@ LIBS= include objects.mk ONE_OBJS+=osdep/BSDEthernetTap.o ext/http-parser/http_parser.o +# Build with address sanitization library for advanced debugging (clang) +ifeq ($(ZT_SANITIZE),1) + SANFLAGS+=-fsanitize=address -DASAN_OPTIONS=symbolize=1 +endif # "make debug" is a shortcut for this ifeq ($(ZT_DEBUG),1) CFLAGS+=-Wall -Werror -g -pthread $(INCLUDES) $(DEFS) diff --git a/make-linux.mk b/make-linux.mk index 5b6232473..5e0f5b988 100644 --- a/make-linux.mk +++ b/make-linux.mk @@ -55,6 +55,10 @@ ifeq ($(ZT_RULES_ENGINE_DEBUGGING),1) override DEFS+=-DZT_RULES_ENGINE_DEBUGGING endif +# Build with address sanitization library for advanced debugging (clang) +ifeq ($(ZT_SANITIZE),1) + SANFLAGS+=-fsanitize=address -DASAN_OPTIONS=symbolize=1 +endif ifeq ($(ZT_DEBUG),1) override CFLAGS+=-Wall -Wno-deprecated -Werror -g -pthread $(INCLUDES) $(DEFS) override CXXFLAGS+=-Wall -Wno-deprecated -Werror -g -std=c++11 -pthread $(INCLUDES) $(DEFS) diff --git a/make-mac.mk b/make-mac.mk index 4184792f8..811597952 100644 --- a/make-mac.mk +++ b/make-mac.mk @@ -41,6 +41,10 @@ CORE_OBJS+=ext/x64-salsa2012-asm/salsa2012.o DEFS+=-DMACOSX -DZT_USE_MINIUPNPC -DMINIUPNP_STATICLIB -D_DARWIN_C_SOURCE -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNPC_GET_SRC_ADDR -D_BSD_SOURCE -D_DEFAULT_SOURCE -DOS_STRING=\"Darwin/15.0.0\" -DMINIUPNPC_VERSION_STRING=\"2.0\" -DUPNP_VERSION_STRING=\"UPnP/1.1\" -DENABLE_STRNATPMPERR ONE_OBJS+=ext/libnatpmp/natpmp.o ext/libnatpmp/getgateway.o ext/miniupnpc/connecthostport.o ext/miniupnpc/igd_desc_parse.o ext/miniupnpc/minisoap.o ext/miniupnpc/minissdpc.o ext/miniupnpc/miniupnpc.o ext/miniupnpc/miniwget.o ext/miniupnpc/minixml.o ext/miniupnpc/portlistingparse.o ext/miniupnpc/receivedata.o ext/miniupnpc/upnpcommands.o ext/miniupnpc/upnpdev.o ext/miniupnpc/upnperrors.o ext/miniupnpc/upnpreplyparse.o osdep/PortMapper.o +# Build with address sanitization library for advanced debugging (clang) +ifeq ($(ZT_SANITIZE),1) + SANFLAGS+=-fsanitize=address -DASAN_OPTIONS=symbolize=1 +endif # Debug mode -- dump trace output, build binary with -g ifeq ($(ZT_DEBUG),1) ZT_TRACE=1