summaryrefslogtreecommitdiff
path: root/Mk/Features/sanitize.mk
diff options
context:
space:
mode:
Diffstat (limited to 'Mk/Features/sanitize.mk')
-rw-r--r--Mk/Features/sanitize.mk27
1 files changed, 27 insertions, 0 deletions
diff --git a/Mk/Features/sanitize.mk b/Mk/Features/sanitize.mk
new file mode 100644
index 000000000000..6d2e3019705e
--- /dev/null
+++ b/Mk/Features/sanitize.mk
@@ -0,0 +1,27 @@
+# Sanitize Support
+#
+# Variables that can be used:
+#
+# WITH_SANITIZE Enable for all ports.
+# Sanitizer exits for each bug detected, so it is not
+# advisable to enable it globally.
+# WITH_SANITIZE_PORTS Enable for specified category/port-name
+# SANITIZE_FLAGS Comma-separated list of sanitizers to be enabled
+# Default: address
+#
+
+.if !defined(_SANITIZE_MK_INCLUDED)
+_SANITIZE_MK_INCLUDED= yes
+SANITIZE_Include_MAINTAINER= portmgr@FreeBSD.org
+
+. if !defined(SANITIZE_UNSAFE)
+ SANITIZE_FLAGS?= address
+. if defined(_INCLUDE_USES_MESON_MK)
+ MESON_ARGS+= -Db_sanitize=${SANITIZE_FLAGS}
+. else
+ CFLAGS+= -fsanitize=${SANITIZE_FLAGS}
+ CXXFLAGS+= -fsanitize=${SANITIZE_FLAGS}
+ LDFLAGS+= -fsanitize=${SANITIZE_FLAGS}
+. endif
+. endif
+.endif