From 4cb6d5fb56f42339d6c30fe9cad4f32d2dcae415 Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 5 Jun 2018 00:56:51 +0000 Subject: [PATCH] Add rules for building relocatable objects to avoid having random Makefiles use ${LD} ${LDFLAGS} -r which does not work if we specify MKRELRO since LDFLAGS is supposed to be passed to LINK.c not LD directly (although some of the flags work). --- share/mk/bsd.lib.mk | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 4a4c6c16b2e0..edc97680a76a 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.lib.mk,v 1.372 2017/05/29 03:52:43 christos Exp $ +# $NetBSD: bsd.lib.mk,v 1.373 2018/06/05 00:56:51 christos Exp $ # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 .include @@ -541,7 +541,7 @@ _INSTRANLIB=${empty(PRESERVE):?-a "${RANLIB} -t":} .if !target(__archivebuild) __archivebuild: .USE ${_MKTARGET_BUILD} - rm -f ${.TARGET} + @rm -f ${.TARGET} ${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}` .endif @@ -556,6 +556,21 @@ __archivesymlinkpic: .USE ${_MKTARGET_INSTALL} ${INSTALL_SYMLINK} ${.ALLSRC} ${.TARGET} +.if !target(__buildstdlib) +__buildstdlib: .USE + @echo building standard ${.TARGET:T:S/.o//:S/lib//} library + @rm -f ${.TARGET} + @${LINK.c} -nostdlib ${LDFLAGS} -r -o ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}` +.endif + +.if !target(__buildproflib) +__buildproflib: .USE + @echo building profiled ${.TARGET:T:S/.o//:S/lib//} library + ${_MKTARGET_BUILD} + @rm -f ${.TARGET} + @${LINK.c} -nostdlib ${LDFLAGS} -r -o ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*po} | ${TSORT}` +.endif + DPSRCS+= ${_YLSRCS} CLEANFILES+= ${_YLSRCS}