Debian Codegraph @

man/mlton.1

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