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:

Compiler
    This mode translates the given SML# program (.sml file) into LLVM IR and invokes the LLVM compiler to generate machine code.

Linker
    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.

Makefile generator
    This mode analyzes given .sml and .smi files and generates a template of Makefiles that compiles and links the entire project.

Interactive mode
    This mode allows users to input and execute SML# expressions and declarations interactively.

OPTIONS

  Mode Switches

-fsyntax-only
    Run the compiler to check the syntax of the given files. No output file is created.

-ftypecheck-only
    Run the compiler to check the type consistency of the given files. No output file is created.

-S  Run the compiler and produce an assembly file.

-c  Run the compiler and produce an object file.

-M, -MM
    List files relevant to compile the given .sml file in Makefile rule format. -M enumerates all the files, but -MM excludes standard library files.

-Ml, -MMl
    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.

-Mm, -MMm
    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

-o filename
    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.

-v  Be verbose and show commands that smlsharp runs.

  Interactive Mode Options

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

  Compiler Mode Options

-emit-llvm
    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.

-fpic, -fPIC, -fno-pic, -mdynamic-no-pic
    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.

-I directory
    Add the directory to the search path for _require.

-march=arch
-mattr=attributes
-mcpu=cpu
    Specify the target architecture, target attributes, and target processor family of the LLVM IR compiler (llc).

-nostdpath
    Do not search the standard system directories for _require.

-O, -O0, -O1, -O2, -O3, -Os, -Oz
    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.

-target target_triple
    Specify the code generation target for cross-compile.

-Xllc arg
    Pass the additional argument to the LLVM IR compiler (llc).

-Xopt option
    Pass the additional argument to the LLVM IR optimizer (opt).

  Linker Mode Options

-c++
    Use C++ compiler driver instead of C compiler driver.

-llibrary
    Link the specified library with the SML# program.

-L directory
    Add the directory to the search path for libraries.

-nostdlib
    Do not link with the SML# runtime library.

-Wl args, -Xlinker arg
    Pass the additional arugument (comma-separated arguments in args) to the C compiler driver.

  Miscellaneous Options

-B directory
    Set the compiler builtin directory.

-BX directory
    Set the directory of compiler helper commands and internal plugins.

-d [name=value]
    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.

-filemap filename
    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.

--help
    Print help message.

ENVIRONMENT

SMLSHARP_HEAPSIZE
    Set the minimum and maximum size of SML# heap. The default is "32M:256M", which means at least 32MB and at most 256MB.

SMLSHARP_VERBOSE
    Set the verbosity level of the SML# runtime library. The default is 3. Bigger value makes the runtime more verbose.

MYTH_NUM_WORKERS, MTYH_BIND_WORKERS
    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://www.pllab.riec.tohoku.ac.jp/smlsharp/docs/
LLVM Documentation, available at https://llvm.org/docs/