Subject: Re: Cross-compiling
To: None <macbsd-general@sun-lamp.cs.berkeley.edu>
From: Kurt Olsen Unix/Vax/Micro Consultant <KURTO@cc.usu.edu>
List: macbsd-general
Date: 12/02/1993 13:08:12
>From:	IN%"grantham@netcom.com"  2-DEC-1993 03:16:12.19
>Subject: RE: Cross-developing MacBSD
>
>Yes, this definitely possible, especially under NetBSD/386.  In fact, I've
>considered doing the same thing on my 486/66, since my 16MHz Mac II
>crawls through NetBSD/Mac builds.  I guess I want to say two things about
>this:
>
>1) The primary developers are already having a bitch
>of a time getting just the basic utilities compiled, on the native
>system!  I think that, though it is possible to develop a cross-
>development system under, say, Linux for NetBSD/Mac, it may be kind
>of pointless.  It requires porting GCC, GAS, and the GNU binutils package
>to your host OS, managing the MacBSD include and source tree, and
>understanding the kernel code without a working model.  Finally, you
>can hardly tell the difference between a kernel that doesn't work and a
>compiler that generates incorrect output.  It sounds to me like we'll
>be done with the port for your machine around the time you get your
>cross-compiler working.  (This should inflame a lot of people into
>trying.)
>
>			- Brad

Assuming that you've got a relatively normal BSD, then it really wouldn't
be all that difficult to generate a correct compiler.  The largest problem
is going to be making a linker (ld) that'll do the job.

I did something like this a couple of years ago.  At the time I had an
Atari 1040ST (1 MB RAM, 1 720K floppy, no Hard Drive) and I wanted to use
GCC.  Fortunately Jawahar Bammi had already done all the hard work with
the port, but his port was for a native ST compiler and my st just didn't
cut it.  So I said, 'Hey I've got a DECstation right here that isn't
doing anything, why not make a cross-compiler.'  Taking the sources
Jawahar's source tree, with all of his patches, I just used GCC on the
DECstations to compile up his GCC sources.   Worked first time.  Same with
GAS, the only problem was ld, which was byte order dependant on the host
machine (the DECstation).  Luckily it had reasonable sanity checking and
gave plenty of errors allowing me to track down the areas where it had
problems and slap in a fix.  In less than two days I had a working cross
compiler from a little-endian host to a big-endian host.

To make a compiler for macbsd, here's how I would do it:

1) Take my sources for GCC from my macbsd machine and stick them on
   a machine that has the same version (or at least a close version)
   of gcc as you are using under macbsd.

2) Don't change anything, but the locations of libraries and head files,
   and compile.

3) The linker is going to be your biggest problem, but if you are using a
   recent version, even that will be easy because gld has support for cross
   linking.

4) Try building some program on both your macbsd machine and your 486,
   same code, etc.  Then check to see if they're the same, and if they
   are then see if they run.

Shouldn't be overly difficult, especially if you have a NetBSD ([34]86)
machine to host from.

Oh, yeah, you can just copy the libraries and header's directy from your
mac machine.  Maybe somebody who has both, could generate a compiler/header/
library package and maybe some sort of bootstrapping system to load it with.

Well, thanks for your time.

Good luck,
Kurt Olsen

------------------------------------------------------------------------------