cross-compiling LFS

Jack Brown jbrown at kmts.ca
Sun Mar 2 18:59:02 PST 2003


On Sun, 02 Mar 2003 20:18:53 -0600, Adam Trilling wrote:

> As I mentioned on Friday, I attempted to cross-compile an LFS system
> using OpenBSD as a host.  I didn't get very far.
> 
> The problem is this:  in order to build gcc as a cross-compiler, you
> need to have a compiled glibc.  In order to compile glibc on a non-linux
> host, you need a cross-compiler.
> 
> Attempting to build gcc on a system that does not have glibc will cause
> the build to fail because ld can't find crti.o.
> 
> Adam Trilling
> agt10 at columbia.edu
 
The usual way around this is to "bounce" back and forth between the
different build directories. Basically it looks something like this:
- build binutils for the new target
- start building gcc (C only! no C++) using "make -k" so that it will try
to contiune on past errors. (this will fail anyway though, and that is
expected), you also usually have to manually copy over some files
(float.h) from the host system into the build tree.
- install the kernel headers
- start building glibc. again you need to use "make -k" and again this is
expected to fail, but as with the gcc step, install as much as possible.
- finish building gcc, this time you should have enough of glibc
installed that gcc can complete sucessfully
- finish installing glibc. since gcc is now complete, glibc should
compile sucessfully.

then you have a cross-toolchain

I know that what I describe sounds a little harry but still doable. the
sad truth is that it's actually probably harder and you might not get it
to work.  the last time I personally tried this, I used glibc 2.2.5 and
gcc 2.95.3 to build a GNU/Hurd cross-toolchain for a linux host, and
after _lots_ of googling around for info on cross-compiling I eventually
got it to work. I even tried using gcc 3.x but for some reason I couldn't
get it t work at the time. A good place to start is to download the tar
ball for the hurd kernell and read the included INSTALL-cross file for
pointers since the process should still be similar for Linux (except no
need for mig GNUMach or Hurd).

Incidentally the cross-toolchain is only the beginning of your problems
since packages like bash will refuse to compile usin a cross toolchain.
For those you'll probably have to find precompiled versions.  since the
resulting system will be quite dirty (mismatched versions, etc) I sugest
that once you get that far you should do a normal LFS type build to make
the system you actually want to use.

If you manage to get this to work sucessfully let us know I'd be
intrested to hear how things went for you.

Jack Brown
-- 
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