first cross-compiler checkin

Stephen Weeks MLton@sourcelight.com
Sat, 23 Feb 2002 20:50:36 -0800


This is the first set of changes in getting the cross-compiler to
Cygwin working.  I'm not there yet, but many of the regressions pass
with the C backend.  Nothing works yet with the native backend, but it
looks like an easy fix.

I reorganized the directory structure so that when building MLton
files are no longer placed outside of the sources directory (they used
to be placed in ../lib ../include and ../bin).  Along the way, I added
the ability to support multiple hosts (cygwin, linux) simultaneously.
Now everything needed for running lives in the "build" subdirectory,
which looks like this:

	bin/
		mlton
		mllex
		mlyacc
		mlprof
	lib/
		mlton-compile
		world.mlton
		host1/
			*.a
			include/
		host2/
			*.a
			include/
		...

When installing, bin goes to /usr/local/bin and lib goes to
/usr/local/lib/mlton.

Right now, there are two hosts: i686-pc-linux-gnu and i686-pc-cygwin.
I modified the runtime to support a HOST variable that specifies the
host that the runtime should be built for.  There are also a few #if's
in the runtime sources to behave differently depending on whether
__CYGWIN__ or __linux__ is defined.  Most everything appears to be
supported under cygwin, except for signals and ptrace, but there is
still more testing todo.

Because I don't want to depend on the user to install a cross-compiled
gmp, I added the gmp sources back to the runtime directory, and the
runtime make will make libgmp.a for use by the cygwin backend.

Maybe it's a bit silly to not require a cross-compiled gmp, since I am
requiring the user to install a gcc cross-compiler.  I added a script
that I used to build the cross-compiler to the doc directory, and I
will add link to it in the user guide cross-compiler section, when
that exists.

All of this is driven by the new -host flag to mlton, which can take
either "cygwin" or "linux" as an argument.

One question that I have is what's the right thing to do for normal
compiles.  Right now I have references to i686-pc-linux-gnu in several
places where gcc is called (both in the runtime and from the
compiler).  I am guessing that the right thing to do is either to drop
them and leave the host implicit for normal compiles, or to figure the
build host type out dynamically.