[MLton] Porting MLton to Mac OS X

Jesper Louis Andersen jlouis@mongers.org
Fri, 14 Nov 2003 00:52:14 +0100


Quoting Stephen Weeks (sweeks@sweeks.com):

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

I'll comment on this:

> 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.

This is easy. Use the man-pages to look up differences and to ensure which
system calls that are supported. Forget about profiling at the start, though
it will probably be easy to add later. When I ported to NetBSD it was almost
trivial to add #ifdefs to the code which does it.

> 3. Make the regressions work.  
> 4. Make the benchmarks work.  

These 2 steps I skipped and went straight for:

> 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.

Which I boostrapped from SML/NJ. The big diff here is that I use the x86
backend for generating code, whereas you have to use the C backend.

There is one important thing to add, which is that bootstrapping is messy.
I personally allowed for some ugly hacks the first times to get it to work.
When it worked and was bootstrapped it was easy to recompile it.

And I can now happily report that MLton does also work on NetBSD-current
which is the next release of NetBSD. I just tested. It does also seem to 
perform quite much better because of kernel changes. 

-- 
j.