<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="generator" content="AsciiDoc 8.6.8"> <title>CompileTimeOptions</title> <link rel="stylesheet" href="./asciidoc.css" type="text/css"> <link rel="stylesheet" href="./pygments.css" type="text/css"> <script type="text/javascript" src="./asciidoc.js"></script> <script type="text/javascript"> /*<![CDATA[*/ asciidoc.install(); /*]]>*/ </script> <link rel="stylesheet" href="./mlton.css" type="text/css"/> </head> <body class="article"> <div id="banner"> <div id="banner-home"> <a href="./Home">MLton 20130715</a> </div> </div> <div id="header"> <h1>CompileTimeOptions</h1> </div> <div id="content"> <div id="preamble"> <div class="sectionbody"> <div class="paragraph"><p>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 <span class="monospaced">.c</span>, <span class="monospaced">.mlb</span>, <span class="monospaced">.o</span>, <span class="monospaced">.s</span>, and <span class="monospaced">.sml</span>.</p></div> <div class="paragraph"><p>With no arguments, MLton prints the version number and exits. For a usage message, run MLton with an invalid switch, e.g. <span class="monospaced">mlton -z</span>. In the explanation below and in the usage message, for flags that take a number of choices (e.g. <span class="monospaced">{true|false}</span>), the first value listed is the default.</p></div> </div> </div> <div class="sect1"> <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="ulist"><ul> <li> <p> <span class="monospaced">-align <em>n</em></span> </p> <div class="paragraph"><p>Aligns object in memory by the specified alignment (<span class="monospaced">4</span> or <span class="monospaced">8</span>). The default varies depending on architecture.</p></div> </li> <li> <p> <span class="monospaced">-as-opt <em>option</em></span> </p> <div class="paragraph"><p>Pass <em>option</em> to <span class="monospaced">gcc</span> when compiling assembler code. If you wish to pass an option to the assembler, you must use <span class="monospaced">gcc</span>'s <span class="monospaced">-Wa,</span> syntax.</p></div> </li> <li> <p> <span class="monospaced">-cc-opt <em>option</em></span> </p> <div class="paragraph"><p>Pass <em>option</em> to <span class="monospaced">gcc</span> when compiling C code.</p></div> </li> <li> <p> <span class="monospaced">-codegen {native|x86|amd64|c}</span> </p> <div class="paragraph"><p>Generate native code or C code. With <span class="monospaced">-codegen native</span> (<span class="monospaced">-codegen x86</span> or <span class="monospaced">-codegen amd64</span>), MLton typically compiles more quickly and generates better code.</p></div> </li> <li> <p> <span class="monospaced">-const <em>name</em> <em>value</em></span> </p> <div class="paragraph"><p>Set the value of a compile-time constant. Here is a list of available constants, their default values, and what they control.</p></div> <div class="ulist"><ul> <li> <p> <span class="monospaced">Exn.keepHistory {false|true}</span> </p> <div class="paragraph"><p>Enable <span class="monospaced">MLton.Exn.history</span>. See <a href="MLtonExn">MLtonExn</a> for details. There is a performance cost to setting this to <span class="monospaced">true</span>, 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.</p></div> </li> </ul></div> </li> <li> <p> <span class="monospaced">-default-ann <em>ann</em></span> </p> <div class="paragraph"><p>Specify default <a href="MLBasisAnnotations">ML Basis annotations</a>. For example, <span class="monospaced">-default-ann 'warnUnused true'</span> causes unused variable warnings to be enabled by default. A default is overridden by the corresponding annotation in an ML Basis file.</p></div> </li> <li> <p> <span class="monospaced">-default-type <em>type</em></span> </p> <div class="paragraph"><p>Specify the default binding for a primitive type. For example, <span class="monospaced">-default-type word64</span> causes the top-level type <span class="monospaced">word</span> and the top-level structure <span class="monospaced">Word</span> in the <a href="BasisLibrary">Basis Library</a> to be equal to <span class="monospaced">Word64.word</span> and <span class="monospaced">Word64:WORD</span>, respectively. Similarly, <span class="monospaced">-default-type intinf</span> causes the top-level type <span class="monospaced">int</span> and the top-level structure <span class="monospaced">Int</span> in the <a href="BasisLibrary">Basis Library</a> to be equal to <span class="monospaced">IntInf.int</span> and <span class="monospaced">IntInf:INTEGER</span>, respectively.</p></div> </li> <li> <p> <span class="monospaced">-disable-ann <em>ann</em></span> </p> <div class="paragraph"><p>Ignore the specified <a href="MLBasisAnnotations">ML Basis annotation</a> in every ML Basis file. For example, to see <em>all</em> match and unused warnings, compile with</p></div> <div class="listingblock"> <div class="content monospaced"> <pre>-default-ann 'warnUnused true' -disable-ann forceUsed -disable-ann nonexhaustiveMatch -disable-ann redundantMatch -disable-ann warnUnused</pre> </div></div> </li> <li> <p> <span class="monospaced">-export-header <em>file</em></span> </p> <div class="paragraph"><p>Write C prototypes to <em>file</em> for all of the functions in the program <a href="CallingFromCToSML">exported from SML to C</a>.</p></div> </li> <li> <p> <span class="monospaced">-ieee-fp {false|true}</span> </p> <div class="paragraph"><p>Cause the 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 <span class="monospaced">-codegen x86</span>.</p></div> </li> <li> <p> <span class="monospaced">-inline <em>n</em></span> </p> <div class="paragraph"><p>Set the inlining threshold used in the optimizer. The threshold is an approximate measure of code size of a procedure. The default is <span class="monospaced">320</span>.</p></div> </li> <li> <p> <span class="monospaced">-keep {g|o}</span> </p> <div class="paragraph"><p>Save intermediate files. If no <span class="monospaced">-keep</span> argument is given, then only the output file is saved.</p></div> <table class="tableblock frame-all grid-all" style=" width:100%; "> <col style="width:25%;"> <col style="width:75%;"> <tbody> <tr> <td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">g</span></p></td> <td class="tableblock halign-left valign-top" ><p class="tableblock">generated <span class="monospaced">.c</span> and <span class="monospaced">.s</span> files passed to <span class="monospaced">gcc</span></p></td> </tr> <tr> <td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">o</span></p></td> <td class="tableblock halign-left valign-top" ><p class="tableblock">object (<span class="monospaced">.o</span>) files</p></td> </tr> </tbody> </table> </li> <li> <p> <span class="monospaced">-link-opt <em>option</em></span> </p> <div class="paragraph"><p>Pass <em>option</em> to <span class="monospaced">gcc</span> when linking. You can use this to specify library search paths, e.g. <span class="monospaced">-link-opt -Lpath</span>, and libraries to link with, e.g., <span class="monospaced">-link-opt -lfoo</span>, or even both at the same time, e.g. <span class="monospaced">-link-opt '-Lpath -lfoo'</span>. If you wish to pass an option to the linker, you must use <span class="monospaced">gcc</span>'s <span class="monospaced">-Wl,</span> syntax, e.g., <span class="monospaced">-link-opt '-Wl,--export-dynamic'</span>.</p></div> </li> <li> <p> <span class="monospaced">-mlb-path-map <em>file</em></span> </p> <div class="paragraph"><p>Use <em>file</em> as an <a href="MLBasisPathMap">ML Basis path map</a> to define additional MLB path variables. Multiple uses of <span class="monospaced">-mlb-path-map</span> and <span class="monospaced">-mlb-path-var</span> are allowed, with variable definitions in later path maps taking precedence over earlier ones.</p></div> </li> <li> <p> <span class="monospaced">-mlb-path-var <em>name</em> <em>value</em></span> </p> <div class="paragraph"><p>Define an additional MLB path variable. Multiple uses of <span class="monospaced">-mlb-path-map</span> and <span class="monospaced">-mlb-path-var</span> are allowed, with variable definitions in later path maps taking precedence over earlier ones.</p></div> </li> <li> <p> <span class="monospaced">-output <em>file</em></span> </p> <div class="paragraph"><p>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.</p></div> </li> <li> <p> <span class="monospaced">-profile {no|alloc|count|time}</span> </p> <div class="paragraph"><p>Produce an executable that gathers <a href="Profiling"> profiling</a> data. When such an executable is run, it produces an <span class="monospaced">mlmon.out</span> file.</p></div> </li> <li> <p> <span class="monospaced">-profile-branch {false|true}</span> </p> <div class="paragraph"><p>If true, the profiler will separately gather profiling data for each branch of a function definition, <span class="monospaced">case</span> expression, and <span class="monospaced">if</span> expression.</p></div> </li> <li> <p> <span class="monospaced">-profile-stack {false|true}</span> </p> <div class="paragraph"><p>If <span class="monospaced">true</span>, the executable will gather profiling data for all functions on the stack, not just the currently executing function. See <a href="ProfilingTheStack">ProfilingTheStack</a>.</p></div> </li> <li> <p> <span class="monospaced">-profile-val {false|true}</span> </p> <div class="paragraph"><p>If <span class="monospaced">true</span>, the profiler will separately gather profiling data for each (expansive) <span class="monospaced">val</span> declaration.</p></div> </li> <li> <p> <span class="monospaced">-runtime <em>arg</em></span> </p> <div class="paragraph"><p>Pass argument to the runtime system via <span class="monospaced">@MLton</span>. See <a href="RunTimeOptions">RunTimeOptions</a>. The argument will be processed before other <span class="monospaced">@MLton</span> command line switches. Multiple uses of <span class="monospaced">-runtime</span> 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 <span class="monospaced">@MLton</span> or the trailing <span class="monospaced">--</span>; these will be supplied automatically.</p></div> <div class="paragraph"><p>An argument to <span class="monospaced">-runtime</span> may contain spaces, which will cause the argument to be treated as a sequence of words by the runtime. For example the command line:</p></div> <div class="listingblock"> <div class="content monospaced"> <pre>mlton -runtime 'ram-slop 0.4' foo.sml</pre> </div></div> <div class="paragraph"><p>will cause <span class="monospaced">foo</span> to run as if it had been called like:</p></div> <div class="listingblock"> <div class="content monospaced"> <pre>foo @MLton ram-slop 0.4 --</pre> </div></div> <div class="paragraph"><p>An executable created with <span class="monospaced">-runtime stop</span> doesn’t process any <span class="monospaced">@MLton</span> arguments. This is useful to create an executable, e.g., <span class="monospaced">echo</span>, that must treat <span class="monospaced">@MLton</span> like any other command-line argument.</p></div> <div class="listingblock"> <div class="content monospaced"> <pre>% mlton -runtime stop echo.sml % echo @MLton -- @MLton --</pre> </div></div> </li> <li> <p> <span class="monospaced">-show-basis <em>file</em></span> </p> <div class="paragraph"><p>Pretty print to <em>file</em> the basis defined by the input program. See <a href="ShowBasis">ShowBasis</a>.</p></div> </li> <li> <p> <span class="monospaced">-show-def-use <em>file</em></span> </p> <div class="paragraph"><p>Output def-use information to <em>file</em>. Each identifier that is defined appears on a line, followed on subsequent lines by the position of each use.</p></div> </li> <li> <p> <span class="monospaced">-stop {f|g|o|tc}</span> </p> <div class="paragraph"><p>Specify when to stop.</p></div> <table class="tableblock frame-all grid-all" style=" width:100%; "> <col style="width:25%;"> <col style="width:75%;"> <tbody> <tr> <td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">f</span></p></td> <td class="tableblock halign-left valign-top" ><p class="tableblock">list of files on stdout (only makes sense when input is <span class="monospaced">foo.mlb</span>)</p></td> </tr> <tr> <td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">g</span></p></td> <td class="tableblock halign-left valign-top" ><p class="tableblock">generated <span class="monospaced">.c</span> and <span class="monospaced">.s</span> files</p></td> </tr> <tr> <td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">o</span></p></td> <td class="tableblock halign-left valign-top" ><p class="tableblock">object (<span class="monospaced">.o</span>) files</p></td> </tr> <tr> <td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">tc</span></p></td> <td class="tableblock halign-left valign-top" ><p class="tableblock">after type checking</p></td> </tr> </tbody> </table> <div class="paragraph"><p>If you compile with <span class="monospaced">-stop g</span> or <span class="monospaced">-stop o</span>, you can resume compilation by running MLton on the generated <span class="monospaced">.c</span> and <span class="monospaced">.s</span> or <span class="monospaced">.o</span> files.</p></div> </li> <li> <p> <span class="monospaced">-target {self|<em>…</em>}</span> </p> <div class="paragraph"><p>Generate an executable that runs on the specified platform. The default is <span class="monospaced">self</span>, which means to compile for the machine that MLton is running on. To use any other target, you must first install a <a href="CrossCompiling"> cross compiler</a>.</p></div> </li> <li> <p> <span class="monospaced">-target-as-opt <em>target</em> <em>option</em></span> </p> <div class="paragraph"><p>Like <span class="monospaced">-as-opt</span>, this passes <em>option</em> to <span class="monospaced">gcc</span> when compliling assembler code, except it only passes <em>option</em> when the target architecture or operating system is <em>target</em>.</p></div> </li> <li> <p> <span class="monospaced">-target-cc-opt <em>target</em> <em>option</em></span> </p> <div class="paragraph"><p>Like <span class="monospaced">-cc-opt</span>, this passes <em>option</em> to <span class="monospaced">gcc</span> when compiling C code, except it only passes <em>option</em> when the target architecture or operating system is <em>target</em>.</p></div> </li> <li> <p> <span class="monospaced">-target-link-opt <em>target</em> <em>option</em></span> </p> <div class="paragraph"><p>Like <span class="monospaced">-link-opt</span>, this passes <em>option</em> to <span class="monospaced">gcc</span> when linking, except it only passes <em>option</em> when the target architecture or operating system is <em>target</em>.</p></div> </li> <li> <p> <span class="monospaced">-verbose {0|1|2|3}</span> </p> <div class="paragraph"><p>How verbose to be about what passes are running. The default is <span class="monospaced">0</span>.</p></div> <table class="tableblock frame-all grid-all" style=" width:100%; "> <col style="width:25%;"> <col style="width:75%;"> <tbody> <tr> <td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">0</span></p></td> <td class="tableblock halign-left valign-top" ><p class="tableblock">silent</p></td> </tr> <tr> <td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">1</span></p></td> <td class="tableblock halign-left valign-top" ><p class="tableblock">calls to compiler, assembler, and linker</p></td> </tr> <tr> <td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">2</span></p></td> <td class="tableblock halign-left valign-top" ><p class="tableblock">1, plus intermediate compiler passes</p></td> </tr> <tr> <td class="tableblock halign-center valign-top" ><p class="tableblock"><span class="monospaced">3</span></p></td> <td class="tableblock halign-left valign-top" ><p class="tableblock">2, plus some data structure sizes</p></td> </tr> </tbody> </table> </li> </ul></div> </div> </div> </div> <div id="footnotes"><hr></div> <div id="footer"> <div id="footer-text"> </div> <div id="footer-badges"> </div> </div> </body> </html>