Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/share/mk Refactor MKSANITIZER flags in mk rules
details: https://anonhg.NetBSD.org/src/rev/59d56dc8b0fe
branches: trunk
changeset: 323577:59d56dc8b0fe
user: kamil <kamil%NetBSD.org@localhost>
date: Thu Jun 21 11:24:38 2018 +0000
description:
Refactor MKSANITIZER flags in mk rules
Introduce a new variable SANITIZERFLAGS that contains all the sanitizer
specific flags. These flags are designed to be passed to CFLAGS, CXXFLAGS
and LDFLAGS.
Pass SANITIZERFLAGS in bsd.prog.mk rules to CFLAGS, CXXFLAGS and LDFLAGS.
Pass SANITIZERFLAGS in bsd.lib.mk rules to *_pic.a build flags. The *_pic.a
libraries are designed to construct .so libraries. All .so libraries with
few exceptions are expected to be prebuilt with a sanitizer. Another
purpuse of *_pic.a files can be constructing static PIE programs, however
they are not supported as of now and there is no sanitization of static
programs either.
Once MKSTATICPIE will be supported, it will be initially incompatible with
MKSANITIZER.
This change also makes it easier to build other targets like kernel and
kernel modules without userland sanitizers.
No functional change intended for MKSANITIZER=no users.
diffstat:
share/mk/bsd.lib.mk | 5 +++--
share/mk/bsd.prog.mk | 8 +++++++-
share/mk/bsd.sys.mk | 8 ++++----
3 files changed, 14 insertions(+), 7 deletions(-)
diffs (70 lines):
diff -r 380475ec1ee9 -r 59d56dc8b0fe share/mk/bsd.lib.mk
--- a/share/mk/bsd.lib.mk Thu Jun 21 11:02:48 2018 +0000
+++ b/share/mk/bsd.lib.mk Thu Jun 21 11:24:38 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.lib.mk,v 1.374 2018/06/05 15:37:52 christos Exp $
+# $NetBSD: bsd.lib.mk,v 1.375 2018/06/21 11:24:38 kamil Exp $
# @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
.include <bsd.init.mk>
@@ -149,7 +149,7 @@
PICFLAGS ?= -fPIC
.if ${MKPICLIB} != "no"
-CSHLIBFLAGS+= ${PICFLAGS}
+CSHLIBFLAGS+= ${PICFLAGS} ${SANITIZERFLAGS}
.endif
.if defined(CSHLIBFLAGS) && !empty(CSHLIBFLAGS)
@@ -171,6 +171,7 @@
# Platform-independent linker flags for ELF shared libraries
SHLIB_SOVERSION= ${SHLIB_MAJOR}
SHLIB_SHFLAGS= -Wl,-soname,${_LIB}.so.${SHLIB_SOVERSION}
+SHLIB_SHFLAGS+= ${SANITIZERFLAGS}
.if !defined(SHLIB_WARNTEXTREL) || ${SHLIB_WARNTEXTREL} != "no"
SHLIB_SHFLAGS+= -Wl,--warn-shared-textrel
.endif
diff -r 380475ec1ee9 -r 59d56dc8b0fe share/mk/bsd.prog.mk
--- a/share/mk/bsd.prog.mk Thu Jun 21 11:02:48 2018 +0000
+++ b/share/mk/bsd.prog.mk Thu Jun 21 11:24:38 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.prog.mk,v 1.313 2018/06/02 15:19:45 christos Exp $
+# $NetBSD: bsd.prog.mk,v 1.314 2018/06/21 11:24:38 kamil Exp $
# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
.ifndef HOSTPROG
@@ -7,6 +7,12 @@
.include <bsd.shlib.mk>
.include <bsd.gcc.mk>
+##### Sanitizer specific flags.
+
+CFLAGS+= ${SANITIZERFLAGS}
+CXXFLAGS+= ${SANITIZERFLAGS}
+LDFLAGS+= ${SANITIZERFLAGS}
+
#
# Definitions and targets shared among all programs built by a single
# Makefile.
diff -r 380475ec1ee9 -r 59d56dc8b0fe share/mk/bsd.sys.mk
--- a/share/mk/bsd.sys.mk Thu Jun 21 11:02:48 2018 +0000
+++ b/share/mk/bsd.sys.mk Thu Jun 21 11:24:38 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.sys.mk,v 1.282 2018/06/17 23:37:22 christos Exp $
+# $NetBSD: bsd.sys.mk,v 1.283 2018/06/21 11:24:38 kamil Exp $
#
# Build definitions used for NetBSD source tree builds.
@@ -141,9 +141,9 @@
.endif
.if ${MKSANITIZER:Uno} == "yes"
-CFLAGS+= -fsanitize=${USE_SANITIZER}
-CXXFLAGS+= -fsanitize=${USE_SANITIZER}
-LDFLAGS+= -fsanitize=${USE_SANITIZER}
+SANITIZERFLAGS+= -fsanitize=${USE_SANITIZER}
+.else
+SANITIZERFLAGS+= # empty
.endif
Home |
Main Index |
Thread Index |
Old Index