Module Name: src
Committed By: christos
Date: Sat Jun 2 01:41:49 UTC 2018
Modified Files:
src/share/mk: bsd.README bsd.own.mk bsd.sys.mk
Log Message:
Add build glue to build all the code with sanitizers: MKSANITIZE.
To generate a diff of this commit:
cvs rdiff -u -r1.372 -r1.373 src/share/mk/bsd.README
cvs rdiff -u -r1.1062 -r1.1063 src/share/mk/bsd.own.mk
cvs rdiff -u -r1.277 -r1.278 src/share/mk/bsd.sys.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/share/mk/bsd.README
diff -u src/share/mk/bsd.README:1.372 src/share/mk/bsd.README:1.373
--- src/share/mk/bsd.README:1.372 Thu May 31 01:27:46 2018
+++ src/share/mk/bsd.README Fri Jun 1 21:41:49 2018
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.README,v 1.372 2018/05/31 05:27:46 mrg Exp $
+# $NetBSD: bsd.README,v 1.373 2018/06/02 01:41:49 christos Exp $
# @(#)bsd.README 8.2 (Berkeley) 4/2/94
This is the README file for the make "include" files for the NetBSD
@@ -387,6 +387,18 @@ MKREPRO If "yes", create reprodu
result in the same build results.
Default: no
+MKSANITIZER if "yes", use the selected sanitizer to compile userland
+ programs as defined in USE_SANITIZER, which defaults to
+ "memory". Available sanitizers are:
+ address: A memory error detector (default)
+ thread: A data race detector
+ memory: An uninitializer read detector
+ undefined: An undefined behavior detector
+ dataflow: A general data flow analysis
+ cfi: A control flow detector
+ safe-stack: Protect against stack-based corruption
+ Only "address" is currently available for gcc(1)
+
MKSHARE If "no", act as "MKCATPAGES=no MKDOC=no MKHTML=no MKINFO=no
MKMAN=no MKNLS=no".
I.e, don't build catman pages, documentation, Info
Index: src/share/mk/bsd.own.mk
diff -u src/share/mk/bsd.own.mk:1.1062 src/share/mk/bsd.own.mk:1.1063
--- src/share/mk/bsd.own.mk:1.1062 Thu May 31 01:27:46 2018
+++ src/share/mk/bsd.own.mk Fri Jun 1 21:41:49 2018
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.own.mk,v 1.1062 2018/05/31 05:27:46 mrg Exp $
+# $NetBSD: bsd.own.mk,v 1.1063 2018/06/02 01:41:49 christos Exp $
# This needs to be before bsd.init.mk
.if defined(BSD_MK_COMPAT_FILE)
@@ -939,7 +939,7 @@ dependall: .NOTMAIN realdepend .MAKE
#
.for var in \
NOCRYPTO NODOC NOHTML NOINFO NOLINKLIB NOLINT NOMAN NONLS NOOBJ NOPIC \
- NOPICINSTALL NOPROFILE NOSHARE NOSTATICLIB NODEBUGLIB
+ NOPICINSTALL NOPROFILE NOSHARE NOSTATICLIB NODEBUGLIB NOSANITIZER
.if defined(${var})
MK${var:S/^NO//}:= no
.endif
@@ -1091,6 +1091,12 @@ _MKVARS.yes += MKGCCCMDS
MKGCCCMDS?= ${MKGCC}
#
+# Sanitizers, only "address" and "undefined" are supported by gcc
+#
+MKSANITIZER?= no
+USE_SANITIZER?= address
+
+#
# Exceptions to the above:
#
Index: src/share/mk/bsd.sys.mk
diff -u src/share/mk/bsd.sys.mk:1.277 src/share/mk/bsd.sys.mk:1.278
--- src/share/mk/bsd.sys.mk:1.277 Wed May 23 22:06:31 2018
+++ src/share/mk/bsd.sys.mk Fri Jun 1 21:41:49 2018
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.sys.mk,v 1.277 2018/05/24 02:06:31 christos Exp $
+# $NetBSD: bsd.sys.mk,v 1.278 2018/06/02 01:41:49 christos Exp $
#
# Build definitions used for NetBSD source tree builds.
@@ -89,6 +89,12 @@ LDFLAGS+= -Wl,--fatal-warnings
.endif
.endif
+.if ${MKSANITIZER:Uno} == "yes"
+CFLAGS+= -fsanitize=${USE_SANITIZER}
+CXXFLAGS+= -fsanitize=${USE_SANITIZER}
+LDFLAGS+= -fsanitize=${USE_SANITIZER}
+.endif
+
LDFLAGS+= -Wl,--warn-shared-textrel
.if ${WARNS} > 1