Subject: Re: X-compiling (was style guide)
To: None <skippy@macro.stanford.edu>
From: Mark W. Eichin <eichin@kitten.gen.ma.us>
List: current-users
Date: 03/09/1996 00:29:15
> generation is so that gcc can be compiled on a K&R system. The first 
> stage (note: it's been a year; my terminology might be a bit off) 
> compiler for gcc is made to be tolerant of all sort of grossnesses of the 

While the multiple-stage generation may give that impression, in fact
every stage uses the same sources...

All of gcc [the backends and the *C* frontend] is written in k&r
compatibile style. stage1 builds the source with the native-cc; stage2
is built with stage1/gcc; stage3 is build with stage2/gcc, only for
the purpose of comparing stage2 with stage3 and making sure they are
bit-for-bit identical. That comparison serves as a (surprisingly weak)
validation of the correctness of the compiler. (The other reason one
goes as far as stage2 is that gcc presumably has a better optimizer
than native-cc, so the stage2 compiler should be faster...)

Note that the "bootstrap" is only done with the C compiler; C++,
objective-C, and other front ends are then built with the newly
constructed gcc, so they don't need to be written as portably (though
I believe they are anyhow, so one doesn't *have* to bootstrap them.)

> right abstraction of compilers. I.E. the DESTDIR setup needs to know that 
> there are (possibly) 3 compilers: cc for compiling on the host for the 

The terms Cygnus uses are "build, host, target"... for example, we can
build the dos -x- h8/300 toolchain on a sun4; build is sun4, host is
dos, target is h8/300. (This means building both sun4-x-dos and
sun4-x-h8/300 toolchains, so that we can build the compiler that is
hosted on dos *and* the target libraries (libc, libgcc) that get
ultimately used in applications on the h8/300.) I haven't seen this
set up on a netbsd system before, though it should be straightforward;
I'll eventually get around to doing it for m68k-sun-netbsd, but it
would be an interesting exercise (and mostly a matter of diskspace :-)
to pick one host and produce *-*-netbsd targetted compilers for
it. (There are some tricky bits if the wordsize is different, so it
might be hard to use the alpha as the initial host right off...)