diff mbox series

binutils: Specify sysroot for libtool during build

Message ID 20250429092701.3426123-1-raj.khem@gmail.com
State New
Headers show
Series binutils: Specify sysroot for libtool during build | expand

Commit Message

Khem Raj April 29, 2025, 9:27 a.m. UTC
libbfd is enabled and it invokes libtool relink step to get rid of
rpaths during install step. libtool 2.4 patches rightly prepend
lt_sysroot to target libdir which relink step would use, such a patch
is also upstreamed into libtool [1]

However, when we do not specify --with-libtool-sysroot, lt_sysoot prefix
turns out to be empty and relink step adds -L/usr/lib to linker command
line. it cause all sort of problems e.g. when the build host has zlib
installed then libbfd tries to link with /usr/lib/libz.so instead of the
one in target sysroot, fortunately OE linker reports host path contamination
and fails the build. Second problem seen when building target binutils on
musl, it links with libc.so correctly but libtool relink step resolves
libc.so in /usr/lib due to this path and expands it into libc.so.6 and
ld-linux-x86-64.so.2 ( glibc host's libc.so is a linker stub ) in
DT_NEEDED ELF section which does not work with
musl linker and build QA detects this anamoly as well.

ERROR: binutils-2.44-r0 do_package_qa: QA Issue: /usr/lib/libbfd-2.44.so contained in package libbfd requires libc.so.6(GLIBC_2.34)(64bit), but no providers found in RDEPENDS:libbfd? [file-rdeps]

This inconsistency may cause produced binaries mistakenly linked against
libraries from the host distro.

Add libtool sysroot to point libtool to correct sysroot location during
build.

[1] https://git.savannah.gnu.org/cgit/libtool.git/commit/?id=3221f9f0fb98d5740ab5d0e8db6a731302520644

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-devtools/binutils/binutils_2.44.bb | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/binutils/binutils_2.44.bb b/meta/recipes-devtools/binutils/binutils_2.44.bb
index 99b5ce178de..79bcac20254 100644
--- a/meta/recipes-devtools/binutils/binutils_2.44.bb
+++ b/meta/recipes-devtools/binutils/binutils_2.44.bb
@@ -5,6 +5,7 @@  require binutils-${PV}.inc
 DEPENDS += "zlib perl-native"
 
 EXTRA_OECONF += "--with-sysroot=/ \
+                --with-libtool-sysroot=${STAGING_DIR_HOST} \
                 --enable-install-libbfd \
                 --enable-install-libiberty \
                 --enable-shared \