Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Jul 1997 10:55:35 -0500 (CDT)
From:      "Daniel M. Eischen" <deischen@iworks.InterWorks.org>
To:        A.J.Smith@nortel.co.uk, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Cross compiling for FreeBSD 3.0
Message-ID:  <199707301555.KAA18490@iworks.InterWorks.org>

next in thread | raw e-mail | index | archive | help

> I have several linux boxes (2.0.30 kernel) and I want to install GCC as a
> cross-compiler so I can produce FreeBSD binaries.  Can anyone help me out
> and give me some info as to home I might do this?
>
> I have limited access to a FreeBSD 3.0 sytem, so if I need libraries,
> header files and includes I could get them that way, but it is a real
> hassle so I'm hoping I don't need too much.

I've built FreeBSD binaries on a Sparc-Sun-Solaris system.  In lieu of
FreeBSD emulation in Linux, your best bet will be to build ELF binaries
for FreeBSD (3.0-current will support native ELF binaries).   The  
binutils 2.7 (and greater) has support for FreeBSD ELF builtin - you
just need a couple of minor patches to get it to work properly.  If
you wanted to make a.out binaries you'd have to port FreeBSDs ld to
Linux.  I tried doing this for Solaris, but gave up because I didn't
understand it well enough (and ELF was much easier :).

Start with getting the Elfkit from:

  ftp://ftp.polstra.com/pub/FreeBSD/elfkit-1.2.1.tar.gz
  ftp://ftp.polstra.com/pub/FreeBSD/elfkit-1.2.1.patch1

You'll need elfkit-1.2.1.patch1 and binutils-2.6.0.12.patch (the latter
patch coming from the elfkit tarball).  Apply these patches to binutils-2.7
(or 2.8).  Read the READMEs in John Polstras elfkit if you are unsure
how to build a cross compiler - you don't need the elfkit for anything
other than the READMEs and patch.

Pick a directory in which to want your cross-compilation system to
be installed (/usr/local/freebsdelf?) and build the patched binutils
with this prefix.  Get the include files from a 3.0 FreeBSd system
and install them in <prefix>/i386-unknown-freebsdelf/include.  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).

Configure gcc-2.7.2 for i386-unknown-freebsdelf and your chosen prefix.
Build and install gcc.

You're now ready to start cross compiling.  I know I left out some
of the details - I have more precise notes at home if you need them.

Dan Eischen
deischen@iworks.InterWorks.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199707301555.KAA18490>