Debian Codegraph @

man/mlton.1

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