Subject: Cross compilation
To: None <port-pmax@NetBSD.ORG>
From: Arne Henrik Juul <arnej@phys.unit.no>
List: port-pmax
Date: 05/09/1995 01:35:40
    This week we have a Onyx from SGI here on loan for testing etc.
After compiling X11R6 lots of times I decided instead to try to
set up a cross-compilation environment for NetBSD/pmax. Using the
latest gcc and gas snapshot this turned out to be quite easy: I
used the existing mipsel--elf target, and only changed the CPP_PREDEFINES.
(I'm not really sure what should be there, but for now I've got
 -Dmips -DMIPSEL -D__NetBSD__ -Dunix 
 -D__NO_LEADING_UNDERSCORES__ -D__GP_SUPPORT__
which seems to work).

    There are some snags around of course. I haven't tried using the
configuration to build a native compiler yet.
    I had to modify lib/csu/mips/crt0.S to use "_start" instead of
"start". It seems to me "start" would be in the user's namespace, while
"_start" should be reserved as a global identifier. However some
programs use _start. Should this be fixed, or should the toolchain be
hacked to use ___start, or was it OK with just "start"?
    I didn't try to modify starting address etc, so I got 0x00400080,
but this worked OK with a -current kernel. so I guess that's all right.
    Also the archive format is different from the usual netbsd one, so
I had to replace ar/ranlib etc, and also 'make' should probably be told
about it eventually. This shouldn't be too serious though.
    I haven't tried compiling a kernel yet. I've rebuilt large parts
of user-land though, and since - Halleluja! - strip now works, I can
even fit large parts of it onto my disk.

    Some small snags that should be fixed in the tree:
There's the include SYS.h that others have mentioned, in
brk.S and sbrk.S - just move the include lines.
/usr/src/lib/csu/mips/Makefile needs a fix to work right:
--- Makefile.orig	Tue May  9 00:30:39 1995
+++ Makefile	Sun May  7 01:22:35 1995
@@ -13,7 +13,7 @@
 	mv a.out ${.TARGET}
 
 gcrt0.o: crt0.S
-	${COMPILE.S} -DMCRT0 ${.ALLSRC}
+	${COMPILE.S} -DMCRT0 ${.ALLSRC} -o ${.TARGET}
 	${LD} -x -r ${.TARGET}
 	mv a.out ${.TARGET}
 


    That's the status report from Norway :-)

Yours,
    Arne H. Juul