summaryrefslogtreecommitdiff
path: root/makefiles/Makefile.tools
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2018-07-28 10:32:58 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2018-07-28 10:32:58 +0100
commitf2720449b3ede0299da61dfaff9fce6b8db78f75 (patch)
tree24b1aae845d817230b0db04a5db27e974597b378 /makefiles/Makefile.tools
parent0d348add42028c233efead8ea6ce45503fe29c35 (diff)
downloadbuildsystem-f2720449b3ede0299da61dfaff9fce6b8db78f75.tar.gz
buildsystem-f2720449b3ede0299da61dfaff9fce6b8db78f75.tar.bz2
Enable sanitize target for new gccs and clang
Diffstat (limited to 'makefiles/Makefile.tools')
-rw-r--r--makefiles/Makefile.tools19
1 files changed, 19 insertions, 0 deletions
diff --git a/makefiles/Makefile.tools b/makefiles/Makefile.tools
index 86fac4c..33d6add 100644
--- a/makefiles/Makefile.tools
+++ b/makefiles/Makefile.tools
@@ -399,6 +399,25 @@ ifeq ($(toolchain),)
$(error Unable to detect toolchain)
endif
+# Detect if the toolchain ought to support sanitizers
+SANITIZE_OK=no
+ifeq ($(toolchain),gcc)
+ GCC_VERSION := $(shell $(CC) -dumpversion)
+ GCC_MAJOR := $(word 1,$(subst ., ,$(GCC_VERSION)))
+ ifeq ($(shell expr $(GCC_MAJOR) \>= 6),1)
+ SANITIZE_OK=yes
+ endif
+else ifeq ($(toolchain),clang)
+ SANITIZE_OK=yes
+endif
+
+# And fail if we can't sanitize and yet the user asked for it
+ifeq ($(MAKECMDGOALS),sanitize)
+ ifeq ($(SANITIZE_OK),no)
+ $(error Unable to build with sanitizers enabled, compiler not compatible
+ endif
+endif
+
# TODO: It would be nice to avoid this hard-coded path
include $(NSBUILD)/Makefile.$(toolchain)