Add an ASAN option to the Makefile.

ASAN includes DEBUG. ASAN can be overriden by the environment.
This commit is contained in:
Yamagi 2020-10-08 11:53:38 +02:00
parent 0cdfd8f292
commit bf83db4d6d

View file

@ -109,6 +109,11 @@ else
COMPILER := unknown
endif
# ASAN includes DEBUG
ifdef ASAN
DEBUG=1
endif
# ----------
# Base CFLAGS. These may be overridden by the environment.
@ -116,6 +121,9 @@ endif
# will likely break this crappy code.
ifdef DEBUG
CFLAGS ?= -O0 -g -Wall -pipe
ifdef ASAN
CFLAGS += -fsanitize=address
endif
else
CFLAGS ?= -O2 -Wall -pipe -fomit-frame-pointer
endif
@ -266,6 +274,11 @@ else ifeq ($(YQ2_OSTYPE),Windows)
LDFLAGS ?= -L/usr/lib
endif
# Link address sanitizer if requested.
ifdef ASAN
LDFLAGS += -fsanitize=address
endif
# Required libraries.
ifeq ($(YQ2_OSTYPE),Linux)
override LDFLAGS += -lm -ldl -rdynamic