Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jan 2024 20:14:25 GMT
From:      Olivier Cochard <olivier@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 0592024317ab - main - features: Add support to enable sanitizers
Message-ID:  <202401182014.40IKEPn4067663@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by olivier:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0592024317abf61f3b824e4413ca301386c20d80

commit 0592024317abf61f3b824e4413ca301386c20d80
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2024-01-18 20:07:45 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2024-01-18 20:13:43 +0000

    features: Add support to enable sanitizers
    
    Can be activated/deactivated globally via
    WITH_SANITIZE
    
    Can be activated individualy via
    WITH_SANITIZE_PORTS
    
    Each port can individually mark itself as not supporting the feature
    via SANITIZE_UNSAFE=
    
    Approved by:    bapt, arrowd
    Sponsored by:   Netflix
    Differential Revision:  https://reviews.freebsd.org/D43497
---
 Mk/Features/sanitize.mk | 27 +++++++++++++++++++++++++++
 Mk/bsd.port.mk          |  2 +-
 2 files changed, 28 insertions(+), 1 deletion(-)

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
diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index 203b78749fd7..f9eb4aebcb6a 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -1016,7 +1016,7 @@ LC_ALL=		C
 # These need to be absolute since we don't know how deep in the ports
 # tree we are and thus can't go relative.  They can, of course, be overridden
 # by individual Makefiles or local system make configuration.
-_LIST_OF_WITH_FEATURES=	debug lto ssp pie relro bind_now
+_LIST_OF_WITH_FEATURES=	bind_now debug lto pie relro sanitize ssp
 _DEFAULT_WITH_FEATURES=	ssp
 PORTSDIR?=		/usr/ports
 LOCALBASE?=		/usr/local



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401182014.40IKEPn4067663>