This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [RFC] ld sysroot prefix handling
2009/5/27 Daniel Jacobowitz <drow@false.org>:
> You didn't say how you configured the linker, or how you invoked it,
> so it's hard to answer you.
As Mike said, in Gentoo the sysroot for cross-compile toolchains is
always set to /usr/$CTARGET.
So the settings are the following:
ld and gcc sysroot prefix: /usr/armv4tl-softfloat-linux-gnueabi
test C program: /tmp/test.c
int main(void)
{
return 0;
}
linker script:
/usr/armv4tl-softfloat-linux-gnueabi/usr/lib/libusb.so
/* GNU ld script
Since Gentoo has critical dynamic libraries in /lib, and the static versions
in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
run into linking problems. This "fake" dynamic lib is a linker script that
redirects the linker to the real lib. And yes, this works in the cross-
compiling scenario as the sysroot-ed linker will prepend the real path.
See bug http://bugs.gentoo.org/4411 for more info.
*/
OUTPUT_FORMAT ( elf32-littlearm )
GROUP ( /lib/libusb.so )
When compiling the test C program with:
armv4tl-softfloat-linux-gnueabi-gcc test.c
I get entry->sysrooted == TRUE and entry->filename == "/lib/libc.so.6" and the
program compiles.
When I try to do an
armv4tl-softfloat-linux-gnueabi-ld --verbose -T
/usr/armv4tl-softfloat-linux-gnueabi/usr/lib/libusb.so
I get entry->sysrooted == FALSE and entry->filename ==
"/lib/libusb.so" and the file is not found as libusb.so is not
installed on host but installed in
/usr/armv4tl-softfloat-linux-gnueabi/lib/libusb.so.
> I believe that library search directories have the sysroot in their name
> field, but files initially don't. ?Then ldfile_open_file_search adds it.
The problem is _not_ the search path, but only the case where an
absolute path to a library is specified (as it is often done by
libtool for example). Btw, in the ldfile_open_file_search function,
the path is prepended to entry->filename IIRC and entry->sysrooted is
set to TRUE. So either you use the sysrooted field inconsistently or
libc should have /usr/armv4tl-softfloat-linux-gnueabi prepened. With
the change in the patch, both examples compile for me and fixes a
whole bunch of cross-compile problems...
> This script is only going to work if it's linked to from *inside* the
> sysroot. ?If it is, sysrooted should be TRUE already.
I dunno if it is relevant, but gentoo builds its packages in
/tmp/portage/$PACKAGENAME/work/PACKAGENAME in my case.
Best regards,
Sven