From 9240f72512c0357636b2e19554d6141ee21edc5f Mon Sep 17 00:00:00 2001 From: bdrewery Date: Tue, 15 Mar 2016 22:27:29 +0000 Subject: [PATCH] Partially revert r266227 and stop stripping paths in ldscripts. Specifically this fixes /usr/lib/libc.so stripping the paths to the libraries. The reason for this in r266227 was both likely because ld(1) did not fully respect --sysroot until r291226 and because of the lib32 build. The lib32 build does not use --sysroot into the /usr/lib32 path, rather it only uses -L and -B into the /usr/lib32 path and --sysroot into the normal (64bit) /usr/lib. The _LDSCRIPTROOT was added with the ldscript support in bsd.lib.mk so that it builds a 32-bit-sysrooted pathed ldscript in the object directory and then installs a normal unprefixed version in installworld. This commit also fixes the rebuild during install which was broken in r266227. This commit would break DIRDEPS_BUILD build of lib32 but it does not currently have a way to build it anyhow. For example, before this change we had in /usr/lib/libc.so: GROUP ( libc.so.7 libc_nonshared.a libssp_nonshared.a ) Now it is restored to pre-r266227: GROUP ( /lib/libc.so.7 /usr/lib/libc_nonshared.a /usr/lib/libssp_nonshared.a ) The motivation for this is in testing of lld. From emaste: lld does not have built-in search paths (e.g. /lib, /usr/lib) and relies on -L arguments passed by the caller. As the linker is nearly always invoked from the clang driver this is fine other than the fact that /usr/lib/libc.so is an ldscript that refers to libc.so.7 which is in /lib, not /usr/lib. PR: 207980 Reported by: emaste Submitted by: emaste (based on) Differential Revision: https://reviews.freebsd.org/D5637 --- share/mk/bsd.lib.mk | 5 ++++- share/mk/bsd.sys.mk | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 51fb828400a2..4a8fe89196db 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -235,7 +235,6 @@ ${SHLIB_NAME_FULL}: beforelinking ${SHLIB_LINK:R}.ld: ${.CURDIR}/${SHLIB_LDSCRIPT} sed -e 's,@@SHLIB@@,${_LDSCRIPTROOT}${_SHLIBDIR}/${SHLIB_NAME},g' \ -e 's,@@LIBDIR@@,${_LDSCRIPTROOT}${_LIBDIR},g' \ - -e 's,/[^ ]*/,,g' \ ${.ALLSRC} > ${.TARGET} ${SHLIB_NAME_FULL}: ${SHLIB_LINK:R}.ld @@ -339,6 +338,9 @@ _SHLINSTALLFLAGS:= ${_SHLINSTALLFLAGS${ie}} .if !defined(INTERNALLIB) realinstall: _libinstall .ORDER: beforeinstall _libinstall +.if target(${SHLIB_LINK:R}.ld) +_libinstall: ${SHLIB_LINK:R}.ld +.endif _libinstall: .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no" ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ @@ -365,6 +367,7 @@ _libinstall: ${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} ${SHLIB_LINK:R}.ld \ ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} + rm -f ${SHLIB_LINK:R}.ld .for _SHLIB_LINK_LINK in ${SHLIB_LDSCRIPT_LINKS} ${INSTALL_SYMLINK} ${SHLIB_LINK} ${DESTDIR}${_LIBDIR}/${_SHLIB_LINK_LINK} .endfor diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index cf53d861fe23..0e6a07eeb070 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -231,7 +231,7 @@ stage_files.shlib: ${_LIBS:M*.so.*} .endif .if defined(SHLIB_LINK) && commands(${SHLIB_LINK:R}.ld) -_LDSCRIPTROOT?= ${STAGE_OBJTOP} +#_LDSCRIPTROOT?= ${STAGE_OBJTOP} STAGE_AS_SETS+= ldscript STAGE_AS.ldscript+= ${SHLIB_LINK:R}.ld stage_as.ldscript: ${SHLIB_LINK:R}.ld