[MLton] Porting MLton to Mac OS X

Stephen Weeks MLton@mlton.org
Thu, 13 Nov 2003 11:49:13 -0800


> After searching the mailing list archives for information about how to
> port mlton to darwin/powerpc, it seems there is not too much progress in
> this way. Using the C backend mode, would be straight forward. Mac OS X
> inhertis much of the environment of freebsd (10.3 should be quite source
> compatible to linux - at least that is what apple says). But I don't
> really know where to start and don't have too much time to look into it.
> But if someone knowing the mlton-code would assist me I would try it.

We would be happy to help out.  Here are the steps involved in porting
MLton to a new machine.

1. Port the runtime system.  Since Mac OS X is so close to FreeBSD and
   Linux, and MLton run' on both of those, this should be pretty easy.
   It should mostly involve adding some #ifdefs.
2. Build the constants file.  See the constants target in the
   Makefile.  You can build the C file from any machine, and then
   compile (using gcc, not mlton) and run it on the target (OS X)
   machine.
3. Make the regressions work.  There are two ways to work here.  One
   way is to use MLton running under SML/NJ on the target machine.
   Another is to use MLton compiled by MLton running on a machine that
   MLton already runs on.  In this case, you can either use MLton to
   generate the C files and then ship them over to the target machine
   for testing, or you can install a gcc cross-compiler and generate
   and ship executables to the target machine for testing.  In any
   case, it's best to work through all the regressions in the
   regression/ directory (with a couple of exceptions listed in the
   bin/regression script).
4. Make the benchmarks work.  This is similar to the regressions, just
   bigger.
5. Make a self-compile work.  This is a much bigger test and will
   often uncover bugs.  Here, it is probably easiest to use a
   MLton-compiled MLton instead of a (much slower) SML/NJ-compiled
   one, since MLton is so large that compiling takes a while.
6. Run all the tests (regression, benchmark, self-compile) again on
   the target machine with the MLton-compiled compiler.

I've just written all this off the top of my head, so I may have
missed something.  But hopefully this can get you started.  Feel free
to send mail about anything, no matter how simple it may seem -- we
can probably save you a lot of time by sharing our experience.