Scroll to navigation

SMLSHARP(1) General Commands Manual SMLSHARP(1)

NAME

smlsharp - the SML# compiler

SYNOPSIS

smlsharp [options] filename ...

DESCRIPTION

The smlsharp command is a driver that encompasses the SML# compiler, linker, and other useful tools for software development in SML#. Depending on the options and filenames given in the command line argument, smlsharp changes its mode and acts differently. The following modes are provided:

This mode translates the given SML# program (.sml file) into LLVM IR and invokes the LLVM compiler to generate machine code.
Given an SML# interface file (.smi file), this mode searches for target object files to be involved and link them together into an executable file by invoking the C/C++ compiler driver.
This mode analyzes given .sml and .smi files and generates a template of Makefiles that compiles and links the entire project.
This mode allows users to input and execute SML# expressions and declarations interactively.

OPTIONS

Mode Switches

Run the compiler to check the syntax of the given files. No output file is created.
Run the compiler to check the type consistency of the given files. No output file is created.
Run the compiler and produce an assembly file.
Run the compiler and produce an object file.
List files relevant to compile the given .sml file in Makefile rule format. -M enumerates all the files, but -MM excludes standard library files.
List .smi and object files relevant to compile the given .smi file in Makefile rule format. -Ml enumerates all the files, but -MMl excludes standard library files.
Generate a template of Makefile to build the entire project specified by the given .smi files. -Mm enumerates all the files, but -MMm excludes standard library files.

If none of the above options is specified, smlsharp turns into the following mode depending on the given files:

  • If no input file is given, it turns into the interactive mode.
  • If an .smi file and optional object files are given, it links all the relevant object files into an executable file.
  • If an .sml file is given, it compiles the given file and then links it into an executable file.

Common Options

Set the filename of the output file, which depends on the selected mode. The default output file name depends on the mode selected:
  • In compiler mode, the default file name is obtained by replacing the path of the .smi file corresponding to the given .sml file with either .o, .s, .ll, or .bc.
  • In linker mode, the default output is "a.out".
  • Otherwise, the output is written to the standard output.
Be verbose and show commands that smlsharp runs.

Interactive Mode Options

Load and link the library specified by the .smi file before the interactive session starts.

Compiler Mode Options

Generate LLVM files. When used with -S option, this produces LLVM IR file instead of an assembly file. Otherwise, this produces LLVM bitcode file instead of an object file.
Set relocation model of the LLVM IR compiler (llc). If none of the above is specified, target default relocation model is selected. -fpicand-fPIC selects fully relocatable position independent code. -mdynamic-no-pic selects relocatable external references.
Add the directory to the search path for _require.
Specify the target architecture, target attributes, and target processor family of the LLVM IR compiler (llc).
Do not search the standard system directories for _require.
Specify the optimization level. -O0 means no optimization. -O3 enables almost all the optimizations. -O1and-O2 are somewhere between -O0and-O3. -O is equivalent to -O2. -Osand-Oz turns on optimizations for smaller code sizes.
Specify the code generation target for cross-compile.
Pass the additional argument to the LLVM IR compiler (llc).
Pass the additional argument to the LLVM IR optimizer (opt).

Linker Mode Options

Use C++ compiler driver instead of C compiler driver.
Link the specified library with the SML# program.
Add the directory to the search path for libraries.
Do not link with the SML# runtime library.
Pass the additional arugument (comma-separated arguments in args) to the C compiler driver.

Miscellaneous Options

Set the compiler builtin directory.
Set the directory of compiler helper commands and internal plugins.
Set value to the specified compiler developers' option. When name=value is not specified, verbose output for compiler developers is turned on. When -d is used with --help, the list of developers' option is printed.
Specify the default file name mapping. Each line of the file is of the form "=/filename1/filename2/", where filename1 is the default filename that the compiler produces, and filename2 is the replacement.
Print help message.

ENVIRONMENT

Set the minimum and maximum size of SML# heap. The default is "32M:256M", which means at least 32MB and at most 256MB.
Set the verbosity level of the SML# runtime library. The default is 3. Bigger value makes the runtime more verbose.
Parameters for the MassiveThreads library. If none of them is set, the default is the best one for single-threaded programs.

SEE ALSO

cc(1),c++(1),ld(1)
SML# Document, available at https://smlsharp.github.io/en/documents/
LLVM Documentation, available at https://llvm.org/docs/