remake from source fails?

Stephen Weeks MLton@sourcelight.com
Mon, 18 Jun 2001 09:32:07 -0700


> I tried to remake the MLton binary you sent me from sources (so that I could
> use it on my laptop running Red Hat 6.x) and it failed.  This is with
> mlton-20010321-1 as the old installed MLton.  It failed because
> 	../lib/mlton/basic/time.sml
> line 22 tries to refer to MLton.RUsage.rusage, which is unbound, as is
> MLton.RUsage.t.  I assume that this is caused by differences in the MLton
> structure between the old and new MLtons, but I don't get why you need the
> new MLton to make it.
> Any suggestions?

You can not build the new version of MLton with a much older one because of the
library changes (although see below).

> Ok,  I'm  confused.   How  does  the structure MLton get defined in the MLton
> sources.  It looks like it is assumed to be defined already, like  things  in
> the  basis  library.   This seems to me to be a very bad thing to do since it
> means that the output of, for instance,
>     mlton -stop sml xxx.cm
> is NOT standard ML.  Assuming that the basis is there seems fine, but not the
> MLton structure.
> 
> Given this, how does one get a copy of the source to MLton which you can feed
> to some other ML compiler?

You are correct that 'mlton -stop sml src/mlton/mlton.cm' produces SML which
assumes the existence of the MLton structure.  In order to produce SML code that
is valid with an SML compiler with the standard basis library, one needs to
prefix on "stub" code similar to what's in src/lib/mlton-stubs-in-smlnj/.  That
is the code that I use compile MLton with SML/NJ.  When you run
'mlton -stop sml src/mlton/mlton.cm', that code is excluded because of the
conditional '#if' statements in src/lib/mlton-stubs-in-smlnj/source.cm.

Unfortunately, there is no way to define SMLNJ_VERSION for CM using MLton's
command line.  So, you can concatenate those files on manually if you want an NJ
version.  If we ever need to, I can create similar stubs for the Kit or Moscow
ML or whatever.

For compiling with an older version of MLton, you should be able to add on a
stub that extends the old MLton structure to make it look like the new one.
But, it seems easier just to show me the Red Hat 6.* fix.