Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/share/mk/bsd.lib.mk,v rcsdiff: /ftp/cvs/cvsroot/src/share/mk/bsd.lib.mk,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.362 retrieving revision 1.372 diff -u -p -r1.362 -r1.372 --- src/share/mk/bsd.lib.mk 2015/09/08 16:06:42 1.362 +++ src/share/mk/bsd.lib.mk 2017/05/29 03:52:43 1.372 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.lib.mk,v 1.362 2015/09/08 16:06:42 uebayasi Exp $ +# $NetBSD: bsd.lib.mk,v 1.372 2017/05/29 03:52:43 christos Exp $ # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 .include @@ -42,7 +42,9 @@ realinstall: checkver libinstall # XXX: This is needed for programs that link with .a libraries # Perhaps a more correct solution is to always generate _pic.a # files or always have a shared library. -.if defined(MKPIE) && (${MKPIE} != "no") +# Another fix is to provide rcrt0.o like OpenBSD does and +# do relocations for static PIE. +.if defined(MKPIE) && (${MKPIE} != "no") && !defined(NOPIE) CFLAGS+= ${PIE_CFLAGS} AFLAGS+= ${PIE_AFLAGS} .endif @@ -156,7 +158,7 @@ MKSHLIBOBJS= yes MKSHLIBOBJS= no .endif -.if (defined(MKDEBUG) && (${MKDEBUG} != "no")) || \ +.if (${MKDEBUG:Uno} != "no" && !defined(NODEBUG)) || \ (defined(CFLAGS) && !empty(CFLAGS:M*-g*)) # We only add -g to the shared library objects # because we don't currently split .a archives. @@ -187,7 +189,7 @@ FFLAGS+= ${FOPTS} .if defined(CTFCONVERT) .if defined(CFLAGS) && !empty(CFLAGS:M*-g*) CTFFLAGS+= -g -.if defined(HAVE_GCC) && ${HAVE_GCC} >= 48 +.if defined(HAVE_GCC) #CFLAGS+= -gdwarf-2 .endif .endif @@ -407,7 +409,7 @@ _LIB.so:=${_LIB}.so _LIB.so.major:=${_LIB}.so.${SHLIB_MAJOR} _LIB.so.full:=${_LIB}.so.${SHLIB_FULLVERSION} _LIB.so.link:=${_LIB}.so.${SHLIB_FULLVERSION}.link -.if ${MKDEBUG} != "no" +.if ${MKDEBUG:Uno} != "no" && !defined(NODEBUG) _LIB.so.debug:=${_LIB.so.full}.debug .endif .endif @@ -524,8 +526,6 @@ _YLSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YH realall: ${SRCS} ${ALLOBJS:O} ${_LIBS} ${_LIB.so.debug} -MKARZERO?= ${MKREPRO:Uno} - .if ${MKARZERO} == "yes" _ARFL=crsD _ARRANFL=sD @@ -578,6 +578,11 @@ _LIBLDOPTS+= -Wl,-rpath,${SHLIBDIR} \ _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 @@ -628,7 +633,8 @@ ${_LIB.so.full}: ${_LIB.so.link} ${_LIB. ${_MKTARGET_CREATE} ( ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \ --add-gnu-debuglink=${_LIB.so.debug} \ - ${_LIB.so.link} ${_LIB.so.full} \ + ${_LIB.so.link} ${_LIB.so.full}.tmp && \ + mv -f ${_LIB.so.full}.tmp ${_LIB.so.full} \ ) || (rm -f ${.TARGET}; false) ${_LIB.so.link}: ${_MAINLIBDEPS} .else # aka no MKDEBUG @@ -636,10 +642,14 @@ ${_LIB.so.full}: ${_MAINLIBDEPS} .endif ${_MKTARGET_BUILD} rm -f ${.TARGET} - ${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} \ - ${_LDFLAGS.${_LIB}} -o ${.TARGET} ${_LIBLDOPTS} \ + ${LIBCC} ${LDLIBC} -shared ${SHLIB_SHFLAGS} \ + ${_LDFLAGS.${_LIB}} -o ${.TARGET}.tmp ${_LIBLDOPTS} \ -Wl,--whole-archive ${SOLIB} \ -Wl,--no-whole-archive ${_LDADD.${_LIB}} +.if ${MKSTRIPIDENT} != "no" + ${OBJCOPY} -R .ident ${.TARGET}.tmp +.endif + mv -f ${.TARGET}.tmp ${.TARGET} # We don't use INSTALL_SYMLINK here because this is just # happening inside the build directory/objdir. XXX Why does # this spend so much effort on libraries that aren't live??? XXX @@ -652,9 +662,6 @@ ${_LIB.so.full}: ${_MAINLIBDEPS} .endif ${HOST_LN} -sf ${_LIB.so.full} ${_LIB.so}.tmp mv -f ${_LIB.so}.tmp ${_LIB.so} -.if ${MKSTRIPIDENT} != "no" - ${OBJCOPY} -R .ident ${.TARGET} -.endif .if !empty(LOBJS) # { LLIBS?= -lc