SML# Document Version 4.0.0
28 The smlsharp command

28.3 Compile options

The following options controls file search and code generation of the SML# compiler. Options in this category also affects the interactive session and link mode.

-Idir

Add the directory dir to the search path of .smi files. If multiple -I options are specified, the SML# compiler searches .smi file in the given order. Note that this option is also effective in link mode for computing object file list to be linked.

-nostdpath

Search for .smi files only in directories specified by -I options.

-O, -O0, -O1, -O2, -O3, -Os, -Oz

Change the optimization level. -O0 disables optimization. -O1 to -O3 enable optimization. Bigger number allows more aggressive optimization. -O is an alias of -O2. -Os and -Oz makes code size smaller. If more than one of these options are specified, all of them except for the last one are ignored.

--target=target, -mcmodel model, -march arch, -mcpu cpu, -mattr attrs

Set the target, code model, architecture, CPU, and code generation attributes of LLVM’s code generator. model must be either small, medium, large, or kernel. attrs is a comma-separated list of attributes. See LLVM manual or help of llc command for details.

-fpic, -fPIC, -fno-pic, -mdynamic-no-pic

Set the code relocation model. -fpic is an alias of -fPIC. -fPIC forces the code generator to generate relocatable code. -fno-pic is for non-relocatable code. -mdynamic-no-pic means non-relocatable code containing position independent external symbols. See LLVM manual for details. If none of them is specified, the default model is selected depending on the target platform.

-Xllc arg, -Xopt arg

Add arg to the additional arguments to be passed to LLVM’s llc and opt command, which are invoked by smlsharp for code generation. If more than one of them are given, all of them are passed to the LLVM commands in the given order.

-emit-llvm

Output LLVM IR instead of native code when creating a file of compilation result. If in -S mode, smlsharp generates text LLVM IR code instead of assembly code. The default suffix of the output file is changed from .s to .ll. If in -c mode, it generates LLVM bitcode file instead of object file. The default suffix of the output file is changed from .o to .bc.