Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 275666

Summary: sys-devel/binutils: ld should search libraries in its sysroot first
Product: Gentoo Linux Reporter: Sven 'sleipnir' Rebhan <OdinsHorse>
Component: [OLD] Core systemAssignee: Gentoo Toolchain Maintainers <toolchain>
Severity: major CC: maxposedon
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Package list:
Runtime testing required: ---
Attachments: ld should search libs in sysroot first

Description Sven 'sleipnir' Rebhan 2009-06-28 07:08:51 UTC
When cross-compiling and linking against a #4411 linker script, ld will search the library on the host first. For an amd64 host the following test script

echo "Testing with absolute linker script (systems libz)..."
echo "int main(void) { return 0; }" > test.c
echo "GROUP ( /lib/ )" > "${PWD}/"
armv4tl-softfloat-linux-gnueabi-gcc test.c -o test

will fail with

Testing with absolute linker script (systems libz)...
/lib/ file not recognized: File format not recognized
collect2: ld returned 1 exit status

because the lib (/lib/ specified in the linker script is searched on host first. The following patch solves this problem (upstream bug

Reproducible: Always
Comment 1 Sven 'sleipnir' Rebhan 2009-06-28 07:10:53 UTC
Created attachment 195936 [details, diff]
ld should search libs in sysroot first

When ld was configured with a sysroot, it should always search for libraries with absolute filename in this sysroot first. This patch was tested on x86_64-pc-linux-gnu without sysroot and armv4tl-softfloat-linux-gnueabi cross-compilation with sysroot and works fine on both.
Comment 2 SpanKY gentoo-dev 2009-07-05 19:57:51 UTC
*** Bug 266319 has been marked as a duplicate of this bug. ***
Comment 3 SpanKY gentoo-dev 2009-07-20 09:11:49 UTC
patch has been added to binutils-  if things work out, we can also put it into binutils-2.19.1.