From 1a280e91c726ce193c5fdebca030cc3ecbb86685 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 19 Dec 2018 19:31:04 +1100 Subject: [PATCH] Add support for 'sanitizers=...' make option Use make sanitizers=undefined,address to enable undefined and address sanitizers. Closes #2596 --- src/Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Makefile b/src/Makefile index c44be63ea..8bb56d9b9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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))