support WANT_ASAN=1 on make command line in linux.370 and macOS.370
When the address sanitizer is in use for gcc, clang, or visual studio, (-fsanitize=address) define the NetHack preprocessor symbol USING_ADDRESS_SANITIZER.
This commit is contained in:
@@ -146,6 +146,21 @@ typedef uchar nhsym;
|
||||
|
||||
#include "coord.h"
|
||||
|
||||
/* define USING_ADDRESS_SANITIZER if ASAN is in use */
|
||||
#if defined(__clang__)
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(address_sanitizer)
|
||||
#define USING_ADDRESS_SANITIZER
|
||||
#endif /* __has_feature */
|
||||
#endif /* __has_feature(address_sanitizer) */
|
||||
#else /* ?__clang__ */
|
||||
#if defined(__GNUC__) || defined(_MSC_VER)
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
#define USING_ADDRESS_SANITIZER
|
||||
#endif /* __SANITIZE_ADDRESS__ */
|
||||
#endif /* __GNUC__ || _MSC_VER */
|
||||
#endif /* !__clang__ */
|
||||
|
||||
/*
|
||||
* Automatic inclusions for the subsidiary files.
|
||||
* Please don't change the order. It does matter.
|
||||
|
||||
@@ -29,6 +29,9 @@ CCFLAGS = -g
|
||||
# CPLUSPLUS_NEED_DEPSUPPRESS = 1 C++ -Wno-deprecated-copy,
|
||||
# -Wno-deprecated-declarations
|
||||
|
||||
#ifeq "$(WANT_ASAN)" "1"
|
||||
NEED_ASAN=1
|
||||
#endif
|
||||
|
||||
# If you want to override the compiler detection just carried out
|
||||
# uncomment one of the following pairs. Note, however, that
|
||||
@@ -60,6 +63,10 @@ CFLAGS+=-Wmissing-prototypes
|
||||
CFLAGS+=-Wold-style-definition
|
||||
CFLAGS+=-Wstrict-prototypes
|
||||
|
||||
#ifeq "$(NEED_ASAN)" "1"
|
||||
CFLAGS+=-fsanitize=address
|
||||
#endif
|
||||
|
||||
#detection of clang vs gcc
|
||||
CCISCLANG := $(shell echo `$(CC) --version` | grep clang)
|
||||
ifeq "$(CCISCLANG)" ""
|
||||
|
||||
@@ -56,6 +56,10 @@ endif # WANT_WIN_QT
|
||||
#
|
||||
#-INCLUDE multiw-3.370
|
||||
|
||||
ifeq "$(NEED_ASAN)" "1"
|
||||
LFLAGS+=-fsanitize=address
|
||||
endif
|
||||
|
||||
ifeq "$(USE_CURSESLIB)" "1"
|
||||
# default
|
||||
CURSESLIB = -lncurses -ltinfo
|
||||
@@ -159,7 +163,7 @@ WINX11LIB += -lXpm
|
||||
VARDATND0 += rip.xpm
|
||||
endif
|
||||
WINLIB += $(WINX11LIB)
|
||||
LFLAGS=-L/opt/X11/lib
|
||||
LFLAGS+=-L/opt/X11/lib
|
||||
endif # WANT_WIN_X11
|
||||
|
||||
ifdef WANT_WIN_QT
|
||||
@@ -294,7 +298,7 @@ endif # GITSUBMODULES
|
||||
DLLIB = -ldl
|
||||
|
||||
# Only needed for GLIBC stack trace:
|
||||
LFLAGS=-rdynamic
|
||||
LFLAGS+=-rdynamic
|
||||
|
||||
# if TTY_TILES_ESCCODES
|
||||
#WINSRC += tile.c
|
||||
|
||||
@@ -72,6 +72,10 @@ endif # WANT_WIN_QT
|
||||
|
||||
#-INCLUDE multiw-3.370
|
||||
|
||||
ifeq "$(NEED_ASAN)" "1"
|
||||
LFLAGS +=-fsanitize=address
|
||||
endif
|
||||
|
||||
# NetHack sources control
|
||||
NHCFLAGS+=-DDLB
|
||||
NHCFLAGS+=-DHACKDIR=\"$(HACKDIR)\"
|
||||
|
||||
Reference in New Issue
Block a user