Subject: Re: cross compile cheat sheet?
To: Andrew Cagney <cagney@tpgi.com.au>
From: Dan Winship <danw@MIT.EDU>
List: tech-toolchain
Date: 03/19/1999 16:14:14
Well, here's a start:

1) Build a cross compiler. If you're lucky, there will be a package
for what you want in /usr/pkgsrc/cross. (I was lucky, so I don't know
what to do if you're not.)

2) Cross-compiling a kernel is really easy and just works. configure
it like you would normally and then run (eg)

   env PATH=/usr/pkg/cross/powerpc-netbsd/bin:$PATH MACHINE=macppc MACHINE_ARCH=powerpc make depend
   env PATH=/usr/pkg/cross/powerpc-netbsd/bin:$PATH MACHINE=macppc MACHINE_ARCH=powerpc make all

(You may not need the "env" depending on your choice of root shell ;-)

3) You can try to build userland the same way. You'll need a DESTDIR
to build into. You'll probably want to use obj dirs as well, with
OBJMACHINE set in /etc/mk.conf, if you're going to be compiling for
both your host architecture and your target architecture from the same
tree.

There are a handful of programs that build small tools as part of
their build process which then get run to generate files. This
includes at least sh, tn3270, gcc, and a bunch of things in games.
Some of them are set up to use variables like HOST_CC, HOST_LD, etc to
build the local tools, so if you're mucking with your path as above to
get the cross-compilers by default, you'll have to define each of
those additionally by hand. Except then they still won't work because
HOST_CC will end up invoking "as" out of your PATH and get the wrong
one. The alternative is to set CC, LD, AS, etc, etc, etc, to point
into the cross-compiler path and not change PATH, but that seems like
way too much work. I'm betting there's an easier way I just didn't
notice. (Anyone?)

I ended up just letting the build bomb out and then building the host
programs by hand.

Oh, also, when I finished (cross-compiling a powerpc userland from
i386), only the statically-linked programs ended up working. So then I
gave up and ftped installation tarballs.

-- Dan