Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Jul 1997 12:11:01 -0400
From:      "Daniel M. Eischen" <deischen@iworks.InterWorks.org>
To:        A.J.Smith@nortel.co.uk
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Cross compiling for FreeBSD 3.0
Message-ID:  <33E0B900.41C67EA6@iworks.InterWorks.org>

next in thread | raw e-mail | index | archive | help
> Is there more info in the bin utils about doing this?  I've never built
> binutils or gcc myself, having previously relied on the installed
> binaries.

Yes, but John Polstras Elfkit describes what you need to do.  Something
like:

    Extract binutils-2.7 (or 2.8)

    Apply (probably have to hand apply since they are based on
           binutils-2.6) the 2 binutils patches.  The patches
           are very small.

    cd binutils-2.7  # or binutils-2.8
    # Configure should correctly determine your host system as linux,
    # but you could additionally specify
--host=i486-unknown-linux(elf|aout)
    configure --prefix=/usr/local/cross --target=i386-unknown-freebsdelf
    (cd bfd; make headers)
    make CC=cc CFLAGS=-O
    su
    make CC=cc CFLAGS=-O install

> > Get the include files from a 3.0 FreeBSd system
> > and install them in <prefix>/i386-unknown-freebsdelf/include.
> 
> Do I need to take everything in /usr/include and below?

I would (and did).  John gives you directions on how to easily do
this (I've silently thanked John more than a few times :)

    su
    cd /usr
    find -d include | cpio -pdmv
/usr/local/cross/i386-unknown-freebsdelf

> > Grab
> > the necessary libraries from a 3.0 FreeBSD system and place them in
> > <prefix>/i386-unknown-freebsdelf/lib.  (I am assuming you're configuring
> > binutils/gcc for i386-unknown-freebsdelf).
> 
> Yes.  Again, is this everything from /usr/lib?  I have a feeling this will
> be a somewhat massive set of files...

No, just what you are going to link with and the crt* objects.  Usually,
libc should be enough.  Hmm, these have to be elf-built.  It would be
easier if you could build Johns Elfkit on a 3.0 box to get these
libraries.  I don't have my 3.0-current elf-built libs around anymore,
but I do have 2.2 elf-libs.  Perhaps someone with 3.0 elf libs can
make you a tarball so you don't have to do it yourself.

> > Configure gcc-2.7.2 for i386-unknown-freebsdelf and your chosen prefix.
> > Build and install gcc.
> 
> I believe I've seen gcc documentation on this: Setting up gcc as a cross
> compiler, the gcc --target <architecture> etc., is this the right stuff?

Really, all you need to do is in Johns README:

    configure --prefix=/usr/local/elf --target=i386-unknown-freebsdelf
    make CC=cc CFLAGS=-O LIBGCC1=libgcc1.a OLDCC="./xgcc -B./" \
	FLOAT_H=/usr/include/float.h LANGUAGES=c
    su
    make CC=cc CFLAGS=-O LIBGCC1=libgcc1.a OLDCC="./xgcc -B./" \
	FLOAT_H=/usr/include/float.h LANGUAGES=c install

I believe the elf-built libraries are going to be your only hurdle.

Dan Eischen
deischen@iworks.InterWorks.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?33E0B900.41C67EA6>