Subject: Re: Cross compiling NetBSD/i386 -> NetBSD/mac68k
To: None <port-mac68k@NetBSD.ORG>
From: Dave Huang <khym@bga.com>
List: port-mac68k
Date: 09/28/1995 16:34:55
Well, it looks like I didn't get very far with the cross development
stuff. Just when I had time to try messing with it, I lose access to
the Mac :(
Here's how far I managed to get though... the gas and the gcc from the
NetBSD tree seem to work fine for cross compiling. All I had to do was
setenv MACHINE_ARCH m68k and do a make -e in src/gnu/usr.bin/gas and
gcc2 directories.
There was one problem with getting gas to compile; the
config/tc-m68k.h file (which gets copied to targ-cpu.h) defines
something as MID_MACHINE, but since I didn't install the mac68k
includes, MID_MACHINE was MID_I386. I just edited the file to get it
to use MID_M68K instead. That made it compile fine, but I don't know
if it'll give me problems later :) I didn't actually try looking at
the assembler's output to see if was working right.
The linker gave me trouble though... setenv-ing MACHINE_ARCH and doing
the make -e worked fine, so I installed as, cc and its related files,
and ld into a directory and tweaked the kernel Makefile to go look
there for those files. I then configed the kernel and tried to build
it. It actually got amazingly far without any sorts of warnings or
errors. When it got to the fpsp stuff, I had to go edit the fpsp
Makefile to use the cross development tools instead of the normal
ones. Then I did another make, and it got through compiling fpsp
without a hitch. Linking was a different matter though... core dump :)
I used gdb to take a look, and it looks like it's having
endian-difference problems. So, I looked through the ld source and saw
that there were some #ifdef NEED_SWAP sections of code that looked
promising. I added -DNEED_SWAP to CFLAGS, got a few compiler errors
because struct names had changed and stuff, managed to fix everything
up so it'd compile, but I got unresolved functions trying to link
(various byte swapping functions). And that's as far as I got before
finding out that I wouldn't have a Mac to run MacBSD on anyways...
I got the latest binutils (2.5.2, from Nov 1994), btw, but m68k-netbsd
isn't a supported target. I was hoping to use the ld from there...
Anyways, I probably shouldn't be saying this, since I did almost no
testing of the gas and gcc, but it looks like setting up a cross
development system just for compiling kernels is not all that
difficult, although it isn't trivial... A full-fledged cross
development system that is capable of compiling userland binaries
would probably be harder... dunno :)
(the only test I did was to compile a tiny program like
void main(void){char *p=0x12345678; *p = 123;} and see what the
assembly source code looked like.... looked OK to me! :)
--
Name: Dave Huang | Mammal, mammal / their names are called /
INet: khym@bga.com | they raise a paw / the bat, the cat /
FurryMUCK: Dahan | dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 19 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++