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.363 retrieving revision 1.371 diff -u -p -r1.363 -r1.371 --- src/share/mk/bsd.lib.mk 2016/01/31 15:30:14 1.363 +++ src/share/mk/bsd.lib.mk 2017/05/23 00:54:13 1.371 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.lib.mk,v 1.363 2016/01/31 15:30:14 christos Exp $ +# $NetBSD: bsd.lib.mk,v 1.371 2017/05/23 00:54:13 christos Exp $ # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 .include @@ -42,6 +42,11 @@ 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. +# XXX: This breaks profiling (__mcount relocation is wrong) +# XXX: This is why we remove the PIE_CFLAGS from the profile +# built-in rule below. +# 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} @@ -156,7 +161,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 +192,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 @@ -219,7 +224,8 @@ LIBSTRIPSHLIBOBJS= yes .c.po: ${_MKTARGET_COMPILE} - ${COMPILE.c} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET} + # XXX: See __mcount comment above + ${COMPILE.c:S/${PIE_CFLAGS}//} ${PROFFLAGS} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} -pg ${.IMPSRC} -o ${.TARGET} .if defined(CTFCONVERT) ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} .endif @@ -407,7 +413,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 +530,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 +582,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 +637,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 +646,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 +666,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