]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
binutils: Specify sysroot for libtool during build
authorKhem Raj <raj.khem@gmail.com>
Tue, 29 Apr 2025 09:27:01 +0000 (02:27 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 1 May 2025 13:20:18 +0000 (14:20 +0100)
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>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/binutils/binutils_2.44.bb

index 99b5ce178de59d34cb8a29e917ce744108b89130..79bcac20254f63cc7cd14cbe6d05c00f2cde682d 100644 (file)
@@ -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 \