Cross linking our Ch5 build against a new glibc

Greg Schafer gschafer at zip.com.au
Sun Jan 19 19:24:46 PST 2003


On Mon, Jan 20, 2003 at 10:03:16AM +1100, Ryan.Oliver at pha.com.au wrote:
> So Greg, you are absolutely correct, to build a cross linker all we have to
> do is specify --with-lib-path during configure :-)

Yes, but...

It seems to me that we don't really need a cross linker. I know that you've
based your stuff on Bruno Haible's post but from what I can tell, the
current tools just work! gcc-3.2.1 (installed into /static) seems to be
smart enuff to drag in everything (except for the dynamic linker directive)
from /static

Witness the following. This is with binutils NOT tweaked:-
----------------------------------------------------------------------------
tigers-lfs:/static/src# gcc -v foo.c
Reading specs from /static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/specs
Configured with: ../gcc-3.2.1/configure --prefix=/static
--enable-languages=c --disable-nls --disable-shared --with-ld=/static/bin/ld
--with-as=/static/bin/as
Thread model: posix
gcc version 3.2.1
 /static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/cc1 -lang-c -v -D__GNUC__=3
-D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=1 -D__GXX_ABI_VERSION=102 -D__ELF__
-Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__
-D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__
-D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__
-D__tune_i686__ -D__tune_pentiumpro__ foo.c -quiet -dumpbase foo.c -version
-o /tmp/ccFbi9fU.s
GNU CPP version 3.2.1 (cpplib) (i386 Linux/ELF)
GNU C version 3.2.1 (i686-pc-linux-gnu)
        compiled by GNU C version 3.2.1.
ignoring nonexistent directory "/static/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /static/include
 /static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/include
 /usr/include
End of search list.
 /static/bin/as -V -Qy -o /tmp/ccIsZiKI.o /tmp/ccFbi9fU.s
GNU assembler version 2.13.90.0.16 (i686-pc-linux-gnu) using BFD version
2.13.90.0.16 20021126
 /static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/collect2 --eh-frame-hdr -m
elf_i386 -dynamic-linker /static/lib/ld-linux.so.2
/static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/../../../crt1.o
/static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/../../../crti.o
/static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/crtbegin.o
-L/static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1
-L/static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/../../../../i686-pc-linux-gnu/lib
-L/static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/../../.. /tmp/ccIsZiKI.o -lgcc
-lc -lgcc /static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/crtend.o
/static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/../../../crtn.o
----------------------------------------------------------------------------

Notice the last "-L" statement? It is actually pointing to the dir where all
our libs that we want to link against are.

Note also the include search order, which although it searches
/usr/local/include first, it then searches /static/include which is what we
want. I'm not sure if searching /usr/local/include first could be harmful or
not.
 
> This makes life nice and easy, just leaves us with the hack to modify
> --dynamic-linker in gcc

Yes, but I again think you might be approaching this the hard way. gcc
provides a "specs" file for exactly this sort of thing. All I did was tweak
the file:-

/static/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/specs

and changed the reference of /lib/ld-linux.so.2 to /static/lib/ld-linux.so.2

and everything just worked! But your way probably achieves exactly the same
thing.

Anyway, I'm still playing around and experimenting. I haven't even entered
the chroot yet and I still have some reservations about how stuff will work
in there. We'll see..

Greg

PS - when you are you going to start using a decent mail reader that doesn't
mangle the threads? Bloody Lotus Bloats :-)
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-dev' in the subject header of the message



More information about the lfs-dev mailing list