summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Le Cuirot <chewi@gentoo.org>2022-12-26 22:12:13 +0000
committerJames Le Cuirot <chewi@gentoo.org>2023-01-28 22:11:10 +0000
commit134dce1bc828e731dc1b12b4454f8827675a5fc9 (patch)
tree1f3c00afb86b5520110cb2d819b8db95214cbaac /sys-libs/glibc
parentsys-apps/baselayout: keyword 2.13-r1 (diff)
downloadgentoo-134dce1bc828e731dc1b12b4454f8827675a5fc9.tar.gz
gentoo-134dce1bc828e731dc1b12b4454f8827675a5fc9.tar.bz2
gentoo-134dce1bc828e731dc1b12b4454f8827675a5fc9.zip
sys-libs/glibc: Strip prefix from ld scripts for better cross-compiling
The toolchain expects to find the libc's files under its own sysroot. This sysroot is automatically prepended to paths found in ld scripts, such as those installed with glibc. We configure standalone prefix systems with a sysroot, so these paths should not be prefixed. However, Gentoo Prefix has traditionally left them prefixed and stopped the compiler from passing the sysroot to the linker instead. It is better to strip the prefix and let the sysroot do its job, as this makes cross-compiling much less awkward. prefix-guest systems do not have a sysroot applied, as they use the host's libc, but they would not install glibc anyway. This change is not needed for musl, as it does not install any ld scripts. Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Diffstat (limited to 'sys-libs/glibc')
-rw-r--r--sys-libs/glibc/glibc-2.36-r6.ebuild11
-rw-r--r--sys-libs/glibc/glibc-2.36-r7.ebuild11
-rw-r--r--sys-libs/glibc/glibc-9999.ebuild11
3 files changed, 33 insertions, 0 deletions
diff --git a/sys-libs/glibc/glibc-2.36-r6.ebuild b/sys-libs/glibc/glibc-2.36-r6.ebuild
index be82be429c8f..e86bbd923123 100644
--- a/sys-libs/glibc/glibc-2.36-r6.ebuild
+++ b/sys-libs/glibc/glibc-2.36-r6.ebuild
@@ -1314,6 +1314,17 @@ glibc_do_src_install() {
mv "${ED}"/$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"/$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die
fi
+ # We configure toolchains for standalone prefix systems with a sysroot,
+ # which is prepended to paths in ld scripts, so strip the prefix from these.
+ # Before: GROUP ( /foo/lib64/libc.so.6 /foo/usr/lib64/libc_nonshared.a AS_NEEDED ( /foo/lib64/ld-linux-x86-64.so.2 ) )
+ # After: GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) )
+ if [[ -n $(host_eprefix) ]] ; then
+ local file
+ grep -lZIF "ld script" "${ED}/$(alt_usrlibdir)"/lib*.{a,so} 2>/dev/null | while read -rd '' file ; do
+ sed -i "s|$(host_eprefix)/|/|g" "${file}" || die
+ done
+ fi
+
# We'll take care of the cache ourselves
rm -f "${ED}"/etc/ld.so.cache
diff --git a/sys-libs/glibc/glibc-2.36-r7.ebuild b/sys-libs/glibc/glibc-2.36-r7.ebuild
index 7071aab6c547..6f93ac1992b1 100644
--- a/sys-libs/glibc/glibc-2.36-r7.ebuild
+++ b/sys-libs/glibc/glibc-2.36-r7.ebuild
@@ -1314,6 +1314,17 @@ glibc_do_src_install() {
mv "${ED}"/$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"/$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die
fi
+ # We configure toolchains for standalone prefix systems with a sysroot,
+ # which is prepended to paths in ld scripts, so strip the prefix from these.
+ # Before: GROUP ( /foo/lib64/libc.so.6 /foo/usr/lib64/libc_nonshared.a AS_NEEDED ( /foo/lib64/ld-linux-x86-64.so.2 ) )
+ # After: GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) )
+ if [[ -n $(host_eprefix) ]] ; then
+ local file
+ grep -lZIF "ld script" "${ED}/$(alt_usrlibdir)"/lib*.{a,so} 2>/dev/null | while read -rd '' file ; do
+ sed -i "s|$(host_eprefix)/|/|g" "${file}" || die
+ done
+ fi
+
# We'll take care of the cache ourselves
rm -f "${ED}"/etc/ld.so.cache
diff --git a/sys-libs/glibc/glibc-9999.ebuild b/sys-libs/glibc/glibc-9999.ebuild
index 413594ad57c4..23a25b3e5e13 100644
--- a/sys-libs/glibc/glibc-9999.ebuild
+++ b/sys-libs/glibc/glibc-9999.ebuild
@@ -1317,6 +1317,17 @@ glibc_do_src_install() {
mv "${ED}"/$(alt_usrlibdir)/libm-${upstream_pv}.a "${ED}"/$(alt_usrlibdir)/${P}/libm-${upstream_pv}.a || die
fi
+ # We configure toolchains for standalone prefix systems with a sysroot,
+ # which is prepended to paths in ld scripts, so strip the prefix from these.
+ # Before: GROUP ( /foo/lib64/libc.so.6 /foo/usr/lib64/libc_nonshared.a AS_NEEDED ( /foo/lib64/ld-linux-x86-64.so.2 ) )
+ # After: GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) )
+ if [[ -n $(host_eprefix) ]] ; then
+ local file
+ grep -lZIF "ld script" "${ED}/$(alt_usrlibdir)"/lib*.{a,so} 2>/dev/null | while read -rd '' file ; do
+ sed -i "s|$(host_eprefix)/|/|g" "${file}" || die
+ done
+ fi
+
# We'll take care of the cache ourselves
rm -f "${ED}"/etc/ld.so.cache