Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/share/mk Add build glue to build all the code with sanitizer...



details:   https://anonhg.NetBSD.org/src/rev/266354defb6b
branches:  trunk
changeset: 319522:266354defb6b
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jun 02 01:41:49 2018 +0000

description:
Add build glue to build all the code with sanitizers: MKSANITIZE.

diffstat:

 share/mk/bsd.README |  14 +++++++++++++-
 share/mk/bsd.own.mk |  10 ++++++++--
 share/mk/bsd.sys.mk |   8 +++++++-
 3 files changed, 28 insertions(+), 4 deletions(-)

diffs (81 lines):

diff -r 75f8fda25964 -r 266354defb6b share/mk/bsd.README
--- a/share/mk/bsd.README       Sat Jun 02 01:40:52 2018 +0000
+++ b/share/mk/bsd.README       Sat Jun 02 01:41:49 2018 +0000
@@ -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 @@
                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
diff -r 75f8fda25964 -r 266354defb6b share/mk/bsd.own.mk
--- a/share/mk/bsd.own.mk       Sat Jun 02 01:40:52 2018 +0000
+++ b/share/mk/bsd.own.mk       Sat Jun 02 01:41:49 2018 +0000
@@ -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 @@
 #
 .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 @@
 MKGCCCMDS?=    ${MKGCC}
 
 #
+# Sanitizers, only "address" and "undefined" are supported by gcc
+#
+MKSANITIZER?=  no
+USE_SANITIZER?=        address
+
+#
 # Exceptions to the above:
 #
 
diff -r 75f8fda25964 -r 266354defb6b share/mk/bsd.sys.mk
--- a/share/mk/bsd.sys.mk       Sat Jun 02 01:40:52 2018 +0000
+++ b/share/mk/bsd.sys.mk       Sat Jun 02 01:41:49 2018 +0000
@@ -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 @@
 .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



Home | Main Index | Thread Index | Old Index