SML# Document Version 4.0.0
28 The smlsharp command

28.1 Mode switch

The following options specifies an execution mode of the smlsharp command. At most one of these options may be specified in a command line.

--help

Print the help message and exit.

-fsyntax-only

Check the syntax of the given sml files and smi files and exit. Specifying this option together with -o option is not allowed. The result of the syntax check is reported by error messages and exit status.

-ftypecheck-only

Perform the typecheck of the given sml files and smi files and exit. Specifying this option together with -o option is not allowed. The result of the syntax check is reported by error messages and exit status.

-S

Compile the given sml files and generate assembly code files. By default, the name of the output file is obtained by replacing the .sml suffix of the input file name with .s. If only one input file is given, you may specify the name of output file by -o option.

-c

Compile the given sml files and generate object files. By default, the name of the output file is obtained by replacing the .sml suffix of the input file name with .o. If only one input file is given, you may specify the name of output file by -o option.

-Mm

Generate a Makefile that compiles and links programs, the entries of which are specified by the given .smi files as input files. It computes all file dependencies for compiling and linking from the given .smi files. If your project does not use source-generating tools such as ml-lex and ml-yacc, this mode generates a complete Makefile for that project. If -o is specified together, the result is written in the specified output file instead of the standard output.

-MMm

Same as -Mm except that files in the standard library are omitted.

-M

Print the list of source files required to compile each of the given sml files in the format of Makefile rule. If -o is specified together, the result is written in the specified output file instead of the standard output.

-MM

Same as -M except that files in the standard library are omitted.

-Ml

Print the list of object files required when linking a program with each of the given smi files. If -o is specified together, the result is written in the specified output file instead of the standard output.

-MMl

Same as -Ml except that files in the standard library are omitted.

If none of the above options is specified, the execution mode of smlsharp is decided by the input files.

  • If no input file is given, it starts the interactive session.

  • Otherwise, smlsharp goes into link mode. In this mode, the input file list may include at most one .smi or .sml file. If a .smi file is given, it computes the list of .smi files by tracing _require relationship from the given .smi file, searches for an object file corresponding to each .smi file in the list, and links the object files found all together. For details of the object file search, see the description of -filemap option. If a .sml file is given, it compiles the given .sml file to an object file and then obtains the list of object files as if its corresponding .smi file is given as a input file. Any other input files must be object or library files that the system linker accepts. The smlsharp command invokes the system linker and passes the list of input files to the linker.

    Note that in link mode, similarly to the system linker, the order of input files is significant. An object file that has unresolved symbols must precede those that provide them.

    The file name of the executable program is a.out by default. You may specify it by -o option.