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,
.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.
Options
-
-align nAligns object in memory by the specified alignment (
4or8). The default varies depending on architecture. -
-as-opt optionPass option to
ccwhen compiling assembler code. If you wish to pass an option to the assembler, you must usecc’s-Wa,syntax. -
-cc ccSpecify the executable for the C compiler. The C compiler is also invoked to compile assembly (
.sfiles) to object code (.ofiles) and to link object code into an executable. -
-cc-opt optionPass option to
ccwhen compiling C code. -
-codegen {native|amd64|c|llvm|x86}Generate native object code via amd64 assembly, C code, LLVM code, or x86 code or C code. With
-codegen native(-codegen amd64or-codegen x86), MLton typically compiles more quickly and generates better code. -
-const name valueSet 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}Enable
MLton.Exn.history. See MLtonExn for details. 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-ann annSpecify default ML Basis annotations. For example,
-default-ann 'warnUnused true'causes unused variable warnings to be enabled by default. A default is overridden by the corresponding annotation in an ML Basis file. -
-default-type typeSpecify 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-ann annIgnore 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 -disable-ann warnUnused
-
-export-header fileWrite 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. -
-inline nSet 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}Save intermediate files. If no
-keepargument is given, then only the output file is saved.ggenerated
.cand.sfiles passed toccand generated.llfiles passed tollvm-asoobject (
.o) files -
-link-opt optionPass option to
ccwhen 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 usecc’s-Wl,syntax, e.g.,-link-opt '-Wl,--export-dynamic'. -
-llvm-as llvm-asSpecify the executable for the LLVM
.llto.bcassembler; can be used to select a specific version of the tool (e.g.,-llvm-as llvm-as-14). -
-llvm-as-opt optionPass option to
llvm-aswhen assembling (.llto.bc) LLVM code. -
-llvm-llc llcSpecify the executable for the LLVM
.bcto.osystem compiler; can be used to select a specific version of the tool (e.g.,-llvm-as llc-14). -
-llvm-llc-opt optionPass option to
llcwhen compiling (.bcto.o) LLVM code. -
-llvm-opt optSpecify the executable for the LLVM
.bcto.bcoptimizer; can be used to select a specific version of the tool (e.g.,-llvm-opt opt-14). -
-llvm-opt-opt optionPass option to
optwhen optimizing (.bcto.bc) LLVM code. -
-mlb-path-map fileUse file as an ML Basis path map to define additional MLB path variables. Multiple uses of
-mlb-path-mapand-mlb-path-varare allowed, with variable definitions in later path maps taking precedence over earlier ones. -
-mlb-path-var name valueDefine an additional MLB path variable. Multiple uses of
-mlb-path-mapand-mlb-path-varare allowed, with variable definitions in later path maps taking precedence over earlier ones. -
-output fileSpecify 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 produces an
mlmon.outfile. -
-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 executable will gather profiling data for all functions on the stack, not just the currently executing function. See ProfilingTheStack. -
-profile-val {false|true}If
true, the profiler will separately gather profiling data for each (expansive)valdeclaration. -
-runtime argPass argument to the runtime system via
@MLton. See RunTimeOptions. 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.sml
will cause
footo run as if it had been called like:foo @MLton ram-slop 0.4 --
An executable created with
-runtime stopdoesn’t process 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-basis filePretty print to file the basis defined by the input program. See ShowBasis.
-
-show-def-use fileOutput def-use information to file. Each identifier that is defined appears on a line, followed on subsequent lines by the position of each use.
-
-stop {f|g|o|tc}Specify when to stop.
flist of files on stdout (only makes sense when input is
foo.mlb)ggenerated
.cand.sfilesoobject (
.o) filestcafter type checking
If you compile with
-stop gor-stop o, you can resume compilation by running MLton on 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 that MLton is running on. To use any other target, you must first install a cross compiler. -
-target-as-opt target optionLike
-as-opt, this passes option toccwhen compliling assembler code, except it only passes option when the target architecture, operating system, or arch-os pair is target. -
-target-cc-opt target optionLike
-cc-opt, this passes option toccwhen compiling C code, except it only passes option when the target architecture, operating system, or arch-os pair is target. -
-target-link-opt target optionLike
-link-opt, this passes option toccwhen linking, except it only passes option when the target architecture, operating system, or arch-os pair is target. -
-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