1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
|
.TH mlton 1 "July 15, 2013"
.SH NAME
\fBmlton\fP \- whole-program compiler for the Standard ML (SML) programming
language
.SH SYNOPSIS
\fBmlton\fP \fI[option ...] file\fB.\fP{\fBc\fP|\fBmlb\fP|\fBo\fP|\fBsml\fP} [file\fB.\fP{\fBc\fP|\fBo\fP|\fBs\fP|\fBS\fP} ...]\fR
.SH DESCRIPTION
.PP
\fBMLton\fP 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 \fBmlton foo.sml\fP, where
\fBfoo.sml\fP contains a valid SML program, in which case MLton
compiles the program to produce an executable \fBfoo\fP. Since
\fBMLton\fP 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, \fBmlton foo.mlb\fP will compile
the complete SML program described by the basis \fBfoo.mlb\fP, which
may specify both SML files and additional bases. See the \fBMLton
Guide\fP for details.
\fBMLton\fP'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 \fBMLton\fP. \fBMLton\fP
uses the input file suffix to determine the type of input program.
The possibilities are \fB.c\fP, \fB.mlb\fP, \fB.o\fP, \fB.s\fP, and \fB.sml\fP.
With no arguments, \fBMLton\fP prints the version number and exits.
For a usage message, run \fBMLton\fP with an invalid switch, e.g.
\fBmlton \-z\fP. In the explanation below and in the usage message,
for flags that take a number of choices
(e.g. \fI{\fBtrue\fP|\fBfalse\fP}\fR), the first value listed is the
default.
.SH Compile-time options
.TP
\fB\-align \fIn\fP\fR
Aligns objects in memory by the specified alignment (\fB4\fP or \fB8\fP).
The default varies depending on architecture.
.TP
\fB\-as\-opt \fIoption\fP\fR
Pass \fIoption\fP to \fBgcc\fP when compiling assembler code. If you
wish to pass an option to the assembler, you must use \fBgcc\fP's
\fB\-Wa,\fP syntax.
.TP
\fB\-cc\-opt \fIoption\fP\fR
Pass \fIoption\fP to \fBgcc\fP when compiling C code.
.TP
\fB\-codegen \fI{\fBnative\fP|\fBx86\fP|\fBamd64\fP|\fBc\fP}\fP\fR
Generate native code or C code. With \fB\-codegen
native\fP (\fB\-codegen x86\fP or \fB\-codegen amd64\fP), \fBMLton\fP
typically compiles more quickly and generates better code.
.TP
\fB\-const '\fIname value\fP'\fR
Set the value of a compile-time constant. Here is a list of available
constants, their default values, and what they control.
\fBExn.keepHistory \fI{\fBfalse\fP|\fBtrue\fP}\fP\fR
.in +.5i
Enable \fBMLton.Exn.history\fP. There is a performance cost to setting this
to \fBtrue\fP, 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.
.in -.5i
.TP
\fB\-default\-ann \fIann\fP\fR
Specify default ML Basis annotations. For
example, \fB\-default\-ann 'warnUnused true'\fP
causes unused variable warnings to be enabled by default.
Defaults may be overridden by an annotation in an ML Basis file.
.TP
\fB\-default\-type \fItype\fP\fR
Specify the default binding for a primitive type. For example,
\fB\-default\-type word64\fP causes the top-level type \fBword\fP and
the top-level structure \fBWord\fP in the Basis Library to be equal to
\fBWord64.word\fP and \fBWord64:WORD\fP, respectively. Similarly,
\fB\-default\-type intinf\fP causes the top-level type \fBint\fP and
the top-level structure \fBInt\fP in the Basis Library to be equal to
\fBIntInf.int\fP and \fBIntInf:INTEGER\fP, respectively.
.TP
\fB\-disable\-ann \fIann\fP\fR
Ignore the specified ML Basis annotation in every ML Basis File. For example,
to see \fIall\fP match and unused warnings, compile with
\fB\-default\-ann 'warnUnused true'\fP,
\fB\-disable\-ann forceUsed\fP,
\fB\-disable\-ann nonexhaustiveMatch\fP,
\fB\-disable\-ann redundantMatch\fP,
and \fB\-disable\-ann warnUnused\fP.
.TP
\fB\-export\-header \fIfile\fP\fR
Write C prototypes to \fIfile\fP for all of the functions in the
program exported from SML to C.
.TP
\fB\-ieee\-fp \fI{\fBfalse\fP|\fBtrue\fP}\fP\fR
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 \fB\-codegen x86\fP.
.TP
\fB\-inline \fIn\fP\fR
Set the inlining threshold used in the optimizer. The threshold is an
approximate measure of code size of a procedure. The default is 320.
.TP
\fB\-keep \fI{\fBg\fP|\fBo\fP}\fP\fR
Save intermediate files. If no \fB\-keep\fP argument is given, then
only the output file is saved.
.in +.5i
\fBg\fP generated \fB.c\fP and \fB.s\fP files passed to \fBgcc\fP
.br
\fBo\fP object (\fB.o\fP) files
.in -.5i
.TP
\fB\-link\-opt \fIoption\fP\fR
Pass \fIoption\fP to \fBgcc\fP when linking. You can use this to
specify library search paths, e.g. \fB\-link\-opt \-Lpath\fP, and
libraries to link with, e.g. \fB\-link\-opt \-lfoo\fP, or even both at
the same time, e.g. \fB\-link\-opt '\-Lpath \-lfoo'\fP. If you wish to
pass an option to the linker, you must use \fBgcc\fP's \fB\-Wl,\fP
syntax, e.g., \fB\-link\-opt '\-Wl,\-\-export\-dynamic'\fP.
.TP
\fB\-mlb\-path\-map \fIfile\fP\fR
Use \fIfile\fP as an ML Basis path map to define additional MLB path variables.
Multiple uses of \fB\-mlb\-path\-map\fP and \fB\-mlb\-path\-var\fP are
allowed, with variable definitions in later path maps taking
precedence over earlier ones.
.TP
\fB\-mlb\-path\-var '\fIname value\fP'\fR
Define an additional MLB path variable.
Multiple uses of \fB\-mlb\-path\-map\fP and \fB\-mlb\-path\-var\fP are
allowed, with variable definitions in later path maps taking
precedence over earlier ones.
.TP
\fB\-output \fIfile\fP\fR
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.
.TP
\fB\-profile \fI{\fBno\fP|\fBalloc\fP|\fBcount\fP|\fBtime\fP}\fP\fR
Produce an executable that gathers profiling data. When
such an executable is run, it will produce an \fBmlmon.out\fP file.
The man page on \fBmlprof\fP describes how to extract information from
this file.
.TP
\fB\-profile\-branch \fI{\fBfalse\fP|\fBtrue\fP}\fP\fR
If true, the profiler will separately gather profiling data
for each branch of a function definition, \fBcase\fP
expression, and \fBif\fP expression.
.TP
\fB\-profile\-stack \fI{\fBfalse\fP|\fBtrue\fP}\fP\fR
If true, the profiler will gather profiling data for all
functions on the stack, not just the currently executing function.
.TP
\fB\-profile\-val \fI{\fBfalse\fP|\fBtrue\fP}\fP\fR
If true, the profiler will separately gather profiling data
for each (expansive) \fBval\fP declaration.
.TP
\fB\-runtime \fIarg\fP\fR
Pass argument to the runtime system via \fB@MLton\fP. The argument
will be processed before other \fB@MLton\fP command line switches.
Multiple uses of \fB\-runtime\fP are 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 \fB@MLton\fP or the trailing \fB\-\-\fP; these will be
supplied automatically.
An argument to \fB\-runtime\fP may contain spaces, which will cause the
argument to be treated as a sequence of words by the runtime. For
example, the command line:
.in +.5i
\fBmlton \-runtime 'ram\-slop 0.4' foo.sml\fP
.in -.5i
will cause foo to run as if it had been called like
.in +.5i
\fBfoo @MLton ram\-slop 0.4 \-\-\fP
.in -.5i
An executable created with \fB\-runtime stop\fP doesn't process any
\fB@MLton\fP arguments. This is useful to create an executable,
e.g. \fBecho\fP, that must treat \fB@MLton\fP like any other
command-line argument.
.in +.5i
\fB% mlton \-runtime stop echo.sml\fP
.in -.5i
.in +.5i
\fB% echo @MLton \-\-\fP
.in -.5i
.in +.5i
\fB@MLton \-\-\fP
.in -.5i
.TP
\fB\-show\-basis \fIfile\fP\fR
Pretty print to \fIfile\fP the basis defined by the input program.
.TP
\fB\-show\-def\-use \fIfile\fP\fR
Output def-use information to \fIfile\fP. Each identifier that is
defined appears on a line, followed on subsequent lines by the position
of each use.
.TP
\fB\-stop \fI{\fBf\fP|\fBg\fP|\fBo\fP|\fBtc\fP}\fP\fR
Specify when to stop.
.in +.5i
\fBf\fP list of files on stdout (only makes sense when input is \fBfoo.mlb\fP)
.br
\fBg\fP generated \fB.c\fP and \fB.s\fP files
.br
\fBo\fP object (\fB.o\fP) files
.br
\fBtc\fP after type checking
.in -.5i
If you compile \fB\-stop g\fP or \fB\-stop o\fP, you can resume
compilation by running \fBMLton\fP on the generated \fB.c\fP and \fB.s\fP
or \fB.o\fP files.
.TP
\fB\-target \fI{\fBself\fP|...}\fP\fR
Generate an executable that runs on the specified platform. The
default is \fBself\fP, which means to compile for the machine that
\fBMLton\fP is running on. To use any other target, you must first
install a cross compiler. See the \fBMLton Guide\fP for
details.
.TP
\fB\-target\-as\-opt \fItarget\fP \fIoption\fP\fR
Like \fB\-as\-opt\fP, this passes \fIoption\fP to \fBgcc\fP when assembling,
except it only passes \fIoption\fP when the target architecture or
operating system is \fItarget\fP.
.TP
\fB\-target\-cc\-opt \fItarget\fP \fIoption\fP\fR
Like \fB\-cc\-opt\fP, this passes \fIoption\fP to \fBgcc\fP when compiling
C code, except it only passes \fIoption\fP when the target architecture
or operating system is \fItarget\fP.
.TP
\fB\-target\-link\-opt \fItarget\fP \fIoption\fP\fR
Like \fB\-link\-opt\fP, this passes \fIoption\fP to \fBgcc\fP when linking,
except it only passes \fIoption\fP when the target architecture or
operating system is \fItarget\fP.
.TP
\fB\-verbose \fI{\fB0\fP|\fB1\fP|\fB2\fP|\fB3\fP}\fP\fR
How verbose to be about what passes are running. The default is 0.
.in +.5i
\fB0\fP silent
.br
\fB1\fP calls to compiler, assembler, and linker
.br
\fB2\fP 1, plus intermediate compiler passes
.br
\fB3\fP 2, plus some data structure sizes
.in -.5i
.SH Runtime system options
Executables produced by \fBMLton\fP 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 \fB@MLton\fP. The optional
arguments then follow, must be terminated by \fB\-\-\fP, and are
followed by any arguments to the program. The optional arguments are
\fInot\fP made available to the SML program via
\fBCommandLine.arguments\fP. For example, a valid call to
\fBhello-world\fP is:
.in +.5i
\fBhello-world @MLton gc\-summary fixed\-heap 10k \-\- a b c\fP
.in -.5i
In the above example,
\fBCommandLine.arguments () = ["a", "b", "c"]\fP.
It is allowed to have a sequence of \fB@MLton\fP arguments, as in:
.in +.5i
\fBhello-world @MLton gc\-summary \-\- @MLton fixed\-heap 10k \-\- a b c\fP
.in -.5i
Run-time options can also control \fBMLton\fP, as in
.in +.5i
\fBmlton @MLton fixed\-heap 0.5g \-\- foo.sml\fP
.in -.5i
.TP
\fBfixed\-heap \fIx{\fBk\fP|\fBK\fP|\fBm\fP|\fBM\fP|\fBg\fP|\fBG\fP}\fP\fR
Use a fixed size heap of size \fIx\fP, where \fIx\fP is a real number
and the trailing letter indicates its units.
.in +.5i
\fBk\fP or \fBK\fP 1024
.br
\fPm\fP or \fBM\fP 1,048,576
.br
\fBg\fP or \fBG\fP 1,073,741,824
.in -.5i
A value of \fB0\fP means to use almost all the RAM present on the machine.
The heap size used by \fBfixed\-heap\fP includes 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.
.TP
\fBgc\-messages\fP
Print a message at the start and end of every garbage collection.
.TP
\fBgc\-summary\fP
Print a summary of garbage collection statistics upon program
termination.
.TP
\fBload\-world \fIworld\fP\fR
Restart the computation with the file specified by \fIworld\fP, which must have
been created by a call to \fBMLton.World.save\fP by the same
executable. See the \fBMLton Guide\fP for details.
.TP
\fBmax\-heap \fIx{\fBk\fP|\fBK\fP|\fBm\fP|\fBM\fP|\fBg\fP|\fBG\fP}\fP\fR
Run the computation with an automatically resized heap that is never
larger than \fIx\fP, where \fIx\fP is a real number and the trailing
letter indicates the units as with \fBfixed\-heap\fP. The
heap size for \fBmax\-heap\fP is accounted for as with
\fBfixed\-heap\fP.
.TP
\fBmay\-page\-heap \fI{\fBfalse\fP|\fBtrue\fP}\fP\fR
Enable paging the heap to disk when unable to grow the heap to a
desired size.
.TP
\fBno\-load\-world\fP
Disable \fBload\-world\fP. This can be used as an argument to the
compiler via \fB\-runtime no\-load\-world\fP to create executables that
will not load a world. This may be useful to ensure that set-uid
executables do not load some strange world.
.TP
\fBram\-slop \fIx\fP\fR
Multiply \fBx\fP by the amount of RAM on the machine to obtain what
the runtime views as the amount of RAM it can use. Typically \fBx\fP
is less than 1, and is used to account for space used by other
programs running on the same machine.
.TP
\fBstop\fP
Causes the runtime to stop processing \fB@MLton\fP arguments once the
next \fB\-\-\fP is reached. This can be used as an argument to the
compiler via \fB\-runtime stop\fP to create executables that don't
process any \fB@MLton\fP arguments.
.SH 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.
.SH "SEE ALSO"
.BR mlprof (1)
and the \fBMLton Guide\fP.
|