Add support for 'sanitizers=...' make option

Use make sanitizers=undefined,address to enable undefined and address
sanitizers.

Closes #2596
This commit is contained in:
Maxime Coste 2018-12-19 19:31:04 +11:00
parent ef3419edbf
commit 1a280e91c7

View File

@ -20,6 +20,21 @@ else
endif
endif
ifneq (,$(findstring address,$(sanitize)))
CPPFLAGS += -fsanitize=address
LDFLAGS += -lasan
sanitize_suffix := $(sanitize_suffix)a
endif
ifneq (,$(findstring undefined,$(sanitize)))
CPPFLAGS += -fsanitize=undefined
LDFLAGS += -lubsan
sanitize_suffix := $(sanitize_suffix)u
endif
ifneq (,$(sanitize_suffix))
suffix := $(suffix).san_$(sanitize_suffix)
endif
version ?= $(shell if [ -f .version ]; then cat .version; elif [ -d ../.git ]; then git describe --tags HEAD; else echo "unknown"; fi)
sources := $(sort $(wildcard *.cc))