Source-Changes-HG archive

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

[src/trunk]: src Introduce MKSTRIPSYM build option



details:   https://anonhg.NetBSD.org/src/rev/b1b9cc41bfec
branches:  trunk
changeset: 353104:b1b9cc41bfec
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Apr 20 09:29:10 2017 +0000

description:
Introduce MKSTRIPSYM build option

If it's yes, all local symbols of shared libraries are stripped
(default). If it's no, only temporary local symbols are stripped;
for example, symbols of static functions are kept. Keeping such
symbols is useful on using DTrace for userland libraries and
getting a backtrace from a rump server loading modules (shared
libraries).

Proposed and discussed on tech-kern and tech-toolchain

diffstat:

 BUILDING                 |  12 ++++++++++++
 doc/BUILDING.mdoc        |  19 +++++++++++++++++--
 share/man/man5/mk.conf.5 |  17 ++++++++++++++++-
 share/mk/bsd.README      |  11 ++++++++++-
 share/mk/bsd.lib.mk      |   9 +++++++--
 share/mk/bsd.lua.mk      |  12 +++++++++---
 share/mk/bsd.sys.mk      |   7 ++++++-
 7 files changed, 77 insertions(+), 10 deletions(-)

diffs (202 lines):

diff -r 790e84583698 -r b1b9cc41bfec BUILDING
--- a/BUILDING  Thu Apr 20 09:19:19 2017 +0000
+++ b/BUILDING  Thu Apr 20 09:29:10 2017 +0000
@@ -396,6 +396,18 @@
 
                  Default: ``no''
 
+     MKSTRIPSYM  Can be set to ``yes'' or ``no''.  Indicates whether all local
+                 symbols should be stripped from shared libraries.  If ``yes'',
+                 strip all local symbols from shared libraries; the affect is
+                 equivalent to -x option of ld(1). If ``no'', strip only
+                 temporary local symbols; the affect is equivalent to -X
+                 option of ld(1). Keeping non-temporary local symbols such as
+                 static function names is useful on using DTrace for userland
+                 libraries and getting a backtrace from a rump kernel loading
+                 shared libraries.
+
+                 Default: ``yes''
+
      MKUNPRIVED  Can be set to ``yes'' or ``no''.  Indicates whether an
                  unprivileged install will occur.  The user, group,
                  permissions, and file flags, will not be set on the installed
diff -r 790e84583698 -r b1b9cc41bfec doc/BUILDING.mdoc
--- a/doc/BUILDING.mdoc Thu Apr 20 09:19:19 2017 +0000
+++ b/doc/BUILDING.mdoc Thu Apr 20 09:29:10 2017 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: BUILDING.mdoc,v 1.116 2017/02/20 20:56:30 christos Exp $
+.\"    $NetBSD: BUILDING.mdoc,v 1.117 2017/04/20 09:29:10 ozaki-r Exp $
 .\"
 .\" Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -33,7 +33,7 @@
 .\" Toolchain prefix for commands
 .ds toolprefix nb
 .
-.Dd February 20, 2017
+.Dd April 13, 2017
 .Dt BUILDING 8
 .Os NetBSD
 .
@@ -697,6 +697,21 @@
 should be stripped from program binaries and shared libraries.
 .DFLTn
 .
+.It Sy MKSTRIPSYM
+.YorN
+Indicates whether all local symbols should be stripped from shared libraries.
+If
+.Dq yes ,
+strip all local symbols from shared libraries;
+the affect is equivalent to -x option of ld(1). If
+.Dq no ,
+strip only temporary local symbols; the affect is equivalent
+to -X option of ld(1). Keeping non-temporary local symbols
+such as static function names is useful on using DTrace for
+userland libraries and getting a backtrace from a rump kernel
+loading shared libraries.
+.DFLTy
+.
 .It Sy MKUNPRIVED
 .YorN
 Indicates whether an unprivileged install will occur.
diff -r 790e84583698 -r b1b9cc41bfec share/man/man5/mk.conf.5
--- a/share/man/man5/mk.conf.5  Thu Apr 20 09:19:19 2017 +0000
+++ b/share/man/man5/mk.conf.5  Thu Apr 20 09:29:10 2017 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: mk.conf.5,v 1.72 2017/02/16 17:15:26 rin Exp $
+.\"    $NetBSD: mk.conf.5,v 1.73 2017/04/20 09:29:10 ozaki-r Exp $
 .\"
 .\"  Copyright (c) 1999-2003 The NetBSD Foundation, Inc.
 .\"  All rights reserved.
@@ -783,6 +783,21 @@
 should be stripped from program binaries and shared libraries.
 .DFLTn
 .
+.It Sy MKSTRIPSYM
+.YorN
+Indicates whether all local symbols should be stripped from shared libraries.
+If
+.Dq yes ,
+strip all local symbols from shared libraries;
+the affect is equivalent to -x option of ld(1). If
+.Dq no ,
+strip only temporary local symbols; the affect is equivalent
+to -X option of ld(1). Keeping non-temporary local symbols
+such as static function names is useful on using DTrace for
+userland libraries and getting a backtrace from a rump kernel
+loading shared libraries.
+.DFLTy
+.
 .It Sy MKUNPRIVED
 .YorN
 Indicates whether an unprivileged install will occur.
diff -r 790e84583698 -r b1b9cc41bfec share/mk/bsd.README
--- a/share/mk/bsd.README       Thu Apr 20 09:19:19 2017 +0000
+++ b/share/mk/bsd.README       Thu Apr 20 09:29:10 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.README,v 1.358 2017/02/08 03:44:41 kamil Exp $
+#      $NetBSD: bsd.README,v 1.359 2017/04/20 09:29:10 ozaki-r Exp $
 #      @(#)bsd.README  8.2 (Berkeley) 4/2/94
 
 This is the README file for the make "include" files for the NetBSD
@@ -409,6 +409,15 @@
                libraries.
                Default: yes
 
+MKSTRIPSYM     If "yes", strip all local symbols from shared libraries;
+               the affect is equivalent to -x option of ld(1). If "no",
+               strip only temporary local symbols; the affect is equivalent
+               to -X option of ld(1). Keeping non-temporary local symbols
+               such as static function names is useful on using DTrace for
+               userland libraries and getting a backtrace from a rump kernel
+               loading shared libraries.
+               Default: yes
+
 MKTOOLSDEBUG   If "yes" build the tools with debugging symbols.
                Default: no
 
diff -r 790e84583698 -r b1b9cc41bfec share/mk/bsd.lib.mk
--- a/share/mk/bsd.lib.mk       Thu Apr 20 09:19:19 2017 +0000
+++ b/share/mk/bsd.lib.mk       Thu Apr 20 09:29:10 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.lib.mk,v 1.368 2017/01/08 17:40:44 christos Exp $
+#      $NetBSD: bsd.lib.mk,v 1.369 2017/04/20 09:29:11 ozaki-r Exp $
 #      @(#)bsd.lib.mk  8.3 (Berkeley) 4/22/94
 
 .include <bsd.init.mk>
@@ -577,6 +577,11 @@
 _LIBLDOPTS+=   -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR} \
                -L=${SHLIBINSTALLDIR}
 .endif
+.if ${MKSTRIPSYM:Uyes} == "yes"
+_LIBLDOPTS+=   -Wl,-x
+.else
+_LIBLDOPTS+=   -Wl,-X
+.endif
 
 # gcc -shared now adds -lc automatically. For libraries other than libc and
 # libgcc* we add as a dependency the installed shared libc. For libc and
@@ -635,7 +640,7 @@
 .endif
        ${_MKTARGET_BUILD}
        rm -f ${.TARGET}
-       ${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} \
+       ${LIBCC} ${LDLIBC} -shared ${SHLIB_SHFLAGS} \
            ${_LDFLAGS.${_LIB}} -o ${.TARGET} ${_LIBLDOPTS} \
            -Wl,--whole-archive ${SOLIB} \
            -Wl,--no-whole-archive ${_LDADD.${_LIB}}
diff -r 790e84583698 -r b1b9cc41bfec share/mk/bsd.lua.mk
--- a/share/mk/bsd.lua.mk       Thu Apr 20 09:19:19 2017 +0000
+++ b/share/mk/bsd.lua.mk       Thu Apr 20 09:29:10 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.lua.mk,v 1.7 2014/07/19 18:38:34 lneto Exp $
+#      $NetBSD: bsd.lua.mk,v 1.8 2017/04/20 09:29:11 ozaki-r Exp $
 #
 # Build rules and definitions for Lua modules
 
@@ -128,6 +128,13 @@
 DPSRCS+=${LUA_SRCS.${_M}}
 SRCS+=${LUA_SRCS.${_M}}
 
+LUA_LDOPTS=    -Wl,--warn-shared-textrel
+.if ${MKSTRIPSYM:Uyes} == "yes"
+LUA_LDOPTS+=   -Wl,-x
+.else
+LUA_LDOPTS+=   -Wl,-X
+.endif
+
 .NOPATH:               ${LUA_OBJS.${_M}} ${LUA_LOBJ.${_M}} ${LUA_TARG.${_M}}
 .if ${MKLINT} != "no"
 ${LUA_TARG.${_M}}:     ${LUA_LOBJ.${_M}}
@@ -137,8 +144,7 @@
 ${LUA_TARG.${_M}}:     ${LUA_OBJS.${_M}} ${DPADD} ${DPADD.${_M}}
        ${_MKTARGET_BUILD}
        rm -f ${.TARGET}
-       ${CC} -Wl,--warn-shared-textrel \
-           -Wl,-x -shared ${LUA_OBJS.${_M}} \
+       ${CC} ${LUA_LDOPTS} -shared ${LUA_OBJS.${_M}} \
            -Wl,-soname,${LUA_NAME.${_M}} -o ${.TARGET} \
            ${LDADD} ${LDADD.${_M}} ${LDFLAGS} ${LDFLAGS.${_M}}
 
diff -r 790e84583698 -r b1b9cc41bfec share/mk/bsd.sys.mk
--- a/share/mk/bsd.sys.mk       Thu Apr 20 09:19:19 2017 +0000
+++ b/share/mk/bsd.sys.mk       Thu Apr 20 09:29:10 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.sys.mk,v 1.270 2017/03/22 23:11:09 chs Exp $
+#      $NetBSD: bsd.sys.mk,v 1.271 2017/04/20 09:29:11 ozaki-r Exp $
 #
 # Build definitions used for NetBSD source tree builds.
 
@@ -308,6 +308,11 @@
 # ARM big endian needs to preserve $a/$d/$t symbols for the linker.
 OBJCOPYLIBFLAGS_EXTRA=-w -K '[$$][adt]' -K '[$$][adt]\.*'
 .endif
+
+.if ${MKSTRIPSYM:Uyes} == "yes"
 OBJCOPYLIBFLAGS?=${"${.TARGET:M*.po}" != "":?-X:-x} ${OBJCOPYLIBFLAGS_EXTRA}
+.else
+OBJCOPYLIBFLAGS?=-X ${OBJCOPYLIBFLAGS_EXTRA}
+.endif
 
 .endif # !defined(_BSD_SYS_MK_)



Home | Main Index | Thread Index | Old Index