mlton (1) Linux Manual Page
NAME
mlton – whole-program compiler for the Standard ML (SML) programming language
SYNOPSIS
mlton [option …] file.{c|cm|mlb|o|sml} [file.{c|o|s|S} …]
DESCRIPTION
MLton is run from the command line with a collection of options followed by a file name and a list of files with which to compile, assemble, and link with. The simplest case is to run mlton foo.sml, where foo.sml contains a valid SML program, in which case MLton compiles the program to produce an executable foo. Since MLton does not support separate compilation, the program must be the entire program you wish to compile. However, the program may refer to signatures and structures defined in the Basis Library.
Larger programs, spanning many files, may be compiled with the ML Basis system. In this case, mlton foo.mlb will compile the complete SML program described by the basis foo.mlb, which may specify both SML files and additional bases. See the MLton Guide for details.
MLton also supports a limited subset of SML/NJ Compilation Manager (CM) files. For example, mlton foo.cm will compile the complete SML program consisting of the concatenation of all the SML files referred to (either directly or indirectly) by foo.cm.
MLton‘s compile-time options control the name of the output file, the verbosity of compile-time messages, and whether or not certain optimizations are performed. They also can specify which intermediate files are saved and can stop the compilation process early, at some intermediate pass, in which case compilation can be resumed by passing the generated files to MLton. MLton uses the input file suffix to determine the type of input program. The possibilities are .c, .cm, .mlb, .o, .S, and .sml.
With no arguments, MLton prints the version number and exits. For a usage message, run MLton with an invalid switch, e.g. mlton -z. In the explanation below and in the usage message, for flags that take a number of choices (e.g. {true|false}), the first value listed is the default.
Compile-time options
-align{4|8}- Aligns object sizes and doubles in memory by the specified alignment. The default varies depending on architecture.
-as-optoption- Pass option to
gccwhen assembling. -cc-optoption- Pass option to
gccwhen compiling C code. -codegen{native|x86|amd64|c|bytecode}- Generate native code, C code, or byte code. With
-codegen native(-codegen x86or-codegen amd64),MLtontypically compiles more quickly and generates better code. -const ‘name value‘- Set the value of a compile-time constant. Here is a list of available constants, their default values, and what they control.
Exn.keepHistory{false|true} EnableMLton.Exn.history. There is a performance cost to setting this totrue, both in memory usage of exceptions and in run time, because of additional work that must be performed at each exception construction, raise, and handle. -default-annann- Specify default ML Basis annotations. For example,
-default-ann ‘warnUnused true’causes unused variable warnings to be enabled by default. Defaults may be overridden by an annotation in an ML Basis file. -default-typetype- Specify the default binding for a primitive type. For example,
-default-type word64causes the top-level typewordand the top-level structureWordin the Basis Library to be equal toWord64.wordandWord64:WORD, respectively. Similarly,-default-type intinfcauses the top-level typeintand the top-level structureIntin the Basis Library to be equal toIntInf.intandIntInf:INTEGER, respectively. -disable-annann- Ignore the specified ML Basis annotation in every ML Basis File. For example, to see all match and unused warnings, compile with
-default-ann ‘warnUnused true’,-disable-ann forceUsed,-disable-ann nonexhaustiveMatch,-disable-ann redundantMatch, and-disable-ann warnUnused. -export-headerfile- Write C prototypes to file for all of the functions in the program exported from SML to C.
-ieee-fp{false|true}- Cause the x86 native code generator to be pedantic about following the IEEE floating point standard. By default, it is not, because of the performance cost. This only has an effect with
-codegen x86. -inlinen- Set the inlining threshold used in the optimizer. The threshold is an approximate measure of code size of a procedure. The default is 320.
-keep{g|o|sml}- Save intermediate files. If no
-keepargument is given, then only the output file is saved.ggenerated.Sand.cfiles passed to gcc and the assembler
oobject (.o) files
smlSML file -link-optoption- Pass option to
gccwhen linking. You can use this to specify library search paths, e.g.-link-opt -Lpath, and libraries to link with, e.g.-link-opt -lfoo, or even both at the same time, e.g.-link-opt ‘-Lpath -lfoo’. If you wish to pass an option to the linker, you must usegcc‘s-Wl,syntax, e.g.,-link-opt ‘-Wl,–export-dynamic’. -mlb-path-mapfile- Use file as an ML Basis path map to define additional MLB path variables. Multiple uses of
-mlb-path-mapare allowed, with variable definitions in later path maps taking precendence over earlier ones. -outputfile- Specify the name of the final output file. The default name is the input file name with its suffix removed and an appropriate, possibly empty, suffix added.
-profile{no|alloc|count|time}- Produce an executable that gathers profiling data. When such an executable is run, it will produce an
mlmon.outfile. The man page onmlprofdescribes how to extract information from this file. -profile-branch{false|true}- If true, the profiler will separately gather profiling data for each branch of a function definition,
caseexpression, andifexpression. -profile-stack{false|true}- If true, the profiler will gather profiling data for all functions on the stack, not just the currently executing function.
-profile-val{false|true}- If true, the profiler will separately gather profiling data for each (expansive)
valdeclaration. -runtimearg- Pass argument to the runtime system via
@MLton. The argument will be processed before other@MLtoncommand line switches. Multiple uses of-runtimeare allowed, and will pass all the arguments in order. If the same runtime switch occurs more than once, then the last setting will take effect. There is no need to supply the leading@MLtonor the trailing—; these will be supplied automatically.An argument to
-runtimemay contain spaces, which will cause the argument to be treated as a sequence of words by the runtime. For example, the command line:mlton -runtime ‘ram-slop 0.4’ foo.smlwill cause foo to run as if it had been called likefoo @MLton ram-slop 0.4 —An executable created with
-runtime stopdoesn’t proces any@MLtonarguments. This is useful to create an executable, e.g.echo, that must treat@MLtonlike any other command-line argument.% mlton -runtime stop echo.sml% echo @MLton —@MLton — -show-basisfile- Pretty print to file the basis defined by the input program.
-show-def-usefile- Output def-use information to file. Each identifier that is defined appears on a line, follwed on subequent lines by the position of each use.
-stop{f|g|o|sml|tc}- Specify when to stop.
flist of files on stdout (only makes sense when input isfoo.cmorfoo.mlb)
ggenerated.Sand.cfiles
oobject (.o) files
smlSML file (only makes sense when input isfoo.cmorfoo.mlb)
tcafter type checking If you compile-stop gor-stop o, you can resume compilation by runningMLtonon the generated.cand.Sor.ofiles. -target{self|…}- Generate an executable that runs on the specified platform. The default is
self, which means to compile for the machine thatMLtonis running on. To use any other target, you must first install a cross compiler. See theMLton Guidefor details. -target-as-opttarget option- Like
-as-opt, this passes option togccwhen assembling, except it only passes option when the target architecture or operating system is target. Valid values for target are:amd64,hppa,powerpc,sparc,x86,aix,cygwin,darwin,freebsd,hpuxP, linux,mingw,netbsd,openbsd,solaris. -target-cc-opttarget option- Like
-cc-opt, this passes option togccwhen compiling C code, except it only passes option when the target architecture or operating system is target. Valid values for target are as for-target-as-opt. -target-link-opttarget option- Like
-link-opt, this passes option togccwhen linking, except it only passes option when the target architecture or operating system is target. Valid values for target are as for-target-as-opt. -verbose{0|1|2|3}- How verbose to be about what passes are running. The default is 0.
0silent
1calls to compiler, assembler, and linker
21, plus intermediate compiler passes
32, plus some data structure sizes
Runtime system options
Executables produced by MLton take command line arguments that control the runtime system. These arguments are optional, and occur before the executable’s usual arguments. To use these options, the first argument to the executable must be @MLton. The optional arguments then follow, must be terminated by —, and are followed by any arguments to the program. The optional arguments are not made available to the SML program via CommandLine.arguments. For example, a valid call to hello-world is: hello-world @MLton gc-summary fixed-heap 10k — a b c In the above example, CommandLine.arguments () = ["a", "b", "c"].
It is allowed to have a sequence of @MLton arguments, as in: hello-world @MLton gc-summary — @MLton fixed-heap 10k — a b c
Run-time options can also control MLton, as in mlton @MLton fixed-heap 0.5g — foo.sml
fixed-heapx{k|K|m|M|g|G}- Use a fixed size heap of size x, where x is a real number and the trailing letter indicates its units.
korK1024
m orM1,048,576
gorG1,073,741,824 A value of0means to use almost all the RAM present on the machine.The heap size used by
fixed-heapincludes all memory allocated by SML code, including memory for the stack (or stacks, if there are multiple threads). It does not, however, include any memory used for code itself or memory used by C globals, the C stack, or malloc. gc-messages- Print a message at the start and end of every garbage collection.
gc-summary- Print a summary of garbage collection statistics upon program termination.
load-worldworld- Restart the computation with the file specified by world, which must have been created by a call to
MLton.World.saveby the same executable. See theMLton Guidefor details. max-heapx{k|K|m|M|g|G}- Run the computation with an automatically resized heap that is never larger than x, where x is a real number and the trailing letter indicates the units as with
fixed-heap. The heap size formax-heapis accounted for as withfixed-heap. no-load-world- Disable
load-world. This can be used as an argument to the compiler via-runtime no-load-worldto create executables that will not load a world. This may be useful to ensure that set-uid executables do not load some strange world. ram-slopx- Multiply
xby the amount of RAM on the machine to obtain what the runtime views as the amount of RAM it can use. Typicallyxis less than 1, and is used to account for space used by other programs running on the same machine. stop- Causes the runtime to stop processing
@MLtonarguments once the next—is reached. This can be used as an argument to the compiler via-runtime stopto create executables that don’t process any@MLtonarguments.
DIAGNOSTICS
MLton’s type error messages are not in a form suitable for processing by Emacs. For details on how to fix this, see http://mlton.org/Emacs.
SEE ALSO
mlprof(1) and the MLton Guide.
