10 Compiling MLton
If you want to compile MLton, you need either the source rpm
or tgz. You can compile with either MLton or SML/NJ, but
we strongly recommend using MLton, since it generates a much faster
executable.
10.1 Compiling with MLton
To compile with MLton, you need the binary versions of mlton,
mllex, and mlyacc that come with the MLton binary
package. An older, the same, or a newer version of MLton should
work. To build MLton, run make from within the root
directory of the sources. This will build MLton first with the
already installed binary version of MLton and will then rebuild
MLton with itself.
First, the Makefile calls mllex and mlyacc to build the
lexer and parser, and then calls mlton to compile itself. When
making MLton using another version the Makefile automatically uses
mlton-stubs.cm, which will put in enough stubs to emulate the
MLton structure. Once MLton is built, the Makefile will
rebuild MLton with itself, this time using mlton.cm and the
real MLton structure from the basis library. This second round
of compilation is essential in order to achieve a fast and robust
MLton.
Compiling MLton requires at least 256M of actual RAM. Thus, if
your machine has less than this, it is likely that self-compilation
will take a very long time due to paging. Even if you have enough
memory, there simply may not be enough available, due to memory
consumed by other processes. In this case, you may see an Out of
memory message, or self-compilation may become extremely slow. The
only fix is to make sure that enough memory is available.
10.2 Compiling with SML/NJ
To compile with SML/NJ, run make nj-mlton from within the root
directory of the sources. You must use the SML/NJ version 110.44,
which is what MLton is developed with. First, the Makefile calls
mllex and mlyacc to build the lexer and parser. Then, it
calls SML/NJ with the appropriate sources.cm file. Building
with SML/NJ takes some time (5-10 minutes on a 1.6GHz machine).
Unless you are doing compiler development and need rapid
recompilation, we recommend compiling with MLton.