Tag Archives: fsc

F# Compiler fsc.exe Command Line Options

I was having a bit of trouble locating documentation on the command line flags for the F# compiler (fsc.exe) so I thought I’d post the list of flags myself. These can be obtained via fsc.exe –full-help. I’ve also posted them in text-only form. Note that fsc uses the *NIX style – and — flags instead of the standard Windows /.

fsc --full-help

MSR F# Compiler, (c) Microsoft Corporation, All Rights Reserved
F# Version 1.9.2.9, compiling for .NET Framework Version v2.0.50727

Usage: fsc  [imported.dll ... ] [file1.ml [file2.ml ...] ]

Basic options:
  -I : Specify a directory for the include path.
  -r : Reference an F# or .NET assembly.
  -R : Reference an F# or .NET assembly and copy it locally.
  -o : Name the output file.
  -a: Produce a DLL.
  -g: Produce debug file. Disables optimizations if a -O flag is not given.
  --define : Define the given conditional compilation symbol.
  -i: Print the inferred interface of the assembly.
  -doc : Write the xmldoc of the assembly to the given file.
  -Ooff: Disable all optimizations, including JIT.
  -O0: Enable JIT optimizations.
  -O1: Enable JIT and local optimizations.
  -O: Same as -O2 (default unless -g)
  -O2: Same as -O1 but also enables cross module optimizations.
  -O3: Same as -O2 but with increased inlining and lambda lifting.
  --no-mllib:
        Do not implicitly reference mllib.dll or open
        Microsoft.FSharp.Compatibility.OCaml.Pervasives,
        useful if you wish to avoid dependencies on OCaml-compatibility library modules.
  --all-warnings: Print all warnings.
  --no-warnings: Do not print any warnings.
  --warn : Report the given specific warning.
  --no-warn : Do not report the given specific warning.
  --all-warnings-as-errors: Treat all warnings as errors.
  --warn-as-error : Treat the given specific warning as an error.
  --gnu-style-errors: Print line number errors in GNU style.
  --namespace :
        Define the default root namespace which will contain subsequent
        F# modules.
  --open :
        Open the given module as an initial definition for each source
        file, useful if you wish to use an alternative functional programming library.

  --fullpaths: Compiler generates fully qualified paths.
  --clr-root :
        Use to override where the compiler looks for mscorlib.dll and other framework
        components. Often needed when using --cli-version.
  --ml-compatibility: Treat F# keywords which are not OCaml keywords as identifiers.
        Also ignore OCaml-compatibility warnings.
  --copy-local : Locate the given file in the search paths and copy 
        it locally (e.g. a PDB).
  --compiling-fslib: 
  --compiling-mllib: 
  -ifile : Print the inferred interface of the assembly to file.
  --target-exe: Produce an executable with a console
  --target-winexe: Produce an executable which does not have a
        stdin/stdout/stderr
  --target-dll: Produce a DLL
  --target-module: Produce a module that can be added to another assembly
  --auto-resolve: Automatically reference DLLs whose name matches a required
        F# module or namespace. Experimental.
  -c: Compile to a module (--target-module) and
        auto-resolve (--auto-resolve). Experimental.
  --standalone:
        Statically link the F# library and all transitively referenced DLLs
        that depend on the F# library into the assembly being generated.
        Disables the generation of the F# interface and optimization
        resources and renames all types beginning with Microsoft.FSharp,
        making them private to the target assembly. There must be no
        duplicate type names across any statically linked
        assemblies, no code may use reflection on any of the
        types in those assemblies, and no code may export F# library types
        as part of an API.
  --static-link :
        Statically the given assembly and all transitively referenced DLLs
        that depend on this assembly.  NOTE: use an assembly name e.g. mylib
        , not a DLL name, e.g. mylib.dll.
  --keyfile :
        Sign the assembly the given keypair file, as produced
        by the .NET Framework SDK 'sn.exe' tool. This produces
        an assembly with a strong name. This is only relevant if producing
        an assembly to be shared amongst programs from different
        directories, e.g. to be installed in the Global Assembly Cache.
  --public-keyfile :
        Delay sign with the given public key file. The assembly can
        be fully signed later using 'sn.exe' from the .NET Framework SDK.
  --retargetable : Specify that an assembly should be referenced in a
        retargetable fashion. Used to build binaries which are independent of
        the publisher of the referenced DLLs.
  --win32res : Specify a Win32 resource file (.res)
  --platform : Limit which platforms this code can run on:
                x86
                anycpu
        The default is anycpu. Other platform limitation specifications
        such as x64 and Itanium are not yet supported.
  --resource : Embed the specified managed resources (.resource).
        Produce .resource files from .resx files using resgen.exe or resxc.exe.
  --link-resource : Link the specified managed resource
        file (.resource). Produce .resource files from .resx files using resgen.exe
        or resxc.exe. Format may be [,[,public|private]].
  --base-address : Base address for the library to be built.
  --version-file :
  --version :
        Specify the version numbers for the generated .NET assembly
        (e.g. 1.2.0.1).
  --cli-version :
        Specify the CLI version to generate code for, regardless of the CLI you
        have installed at compile time.
        Valid values for this version of F# are:
                1.0
                1.1
                2.0
                build tags such as v2.0.x86chk
        You may have to add the right Framework directory to your include path, e.g.
                --clr-root \WINDOWS\Microsoft.NET\Framework\v1.1.4322
        You should also run the appropriate version of peverify on your
        binaries,e.g C:\Program Files\Microsoft Visual Studio .NET 2003\
        \SDK\v1.1\Bin\PEVerify.exe
        to ensure neither you nor any of the libraries you import
        have used features specific to other versions of the .NET Framework.
  --debug-file :
        Name the debug output file.
  --generate-debug-file:
  --no-debug-file:
        Control whether debug information is produced or not. Unlike -g
        this does not by default turn off optimizations.
  --no-debug-file:
        Control whether debug information is produced or not. Unlike -g
        this does not by default turn off optimizations.
  --generate-html:
        Generate HTML documentation.
  --html-output-directory :
        Output directory for HTML documentation.
  --html-css :
        Set the name of the Cascading Style Sheet for HTML docs.
  --html-namespace-file :
        Set the name of the master namespaces.html file
        assumed to be in the output directory.
  --html-namespace-file-append:
        Append to the master namespace file when generating HTML documentation.
  --no-optimization-data:
        Only add optimization information essential implementing 'inline' 
        constructs. Inhibitscross-module inlining but improves binary compatibility.
  --generate-optimization-data-file:
        Place optional information in a .optdata file associated with the 
        generated assembly.
  --no-interface-data:
        Don't add a resource to the generated assembly containing the
        interface data for use by other F# assemblies. The assembly can then
        only be accessed as a .NET assembly.
  --quotation-data:
        This flag is now obsolete. Use the ReflectedDefinition attribute instead.
  --generate-config-file:
        Generate a config file to ensure that a .exe runs on the
        version of the CLR specified by --cli-version.  The
        file will contain a 'supportedRuntime' XML element.
  --jit-optimize:
  --no-jit-optimize:
  --local-optimize:
  --no-local-optimize:
  --cross-optimize:
  --no-cross-optimize:
        Fine grained control for JIT, local and cross-module optimizations.
  --fast-sublanguage-only:
        Restrict the F# langauge slightly to rule out constructs that are
        more difficult to compile efficiently, leading to more optimization
        opportunities for the compiler. This can significantly improve
        performance. Combines all the --no-ABC flags that follow.
  --no-inner-polymorphism:
        Do not permit inner bindings to be genuinely polymorphic.
  --permit-inner-polymorphism:
  --no-string-interning: Do not intern compiled string constants at runtime.
  --statistics: Show statistics of compiler.
  --progress: Show progress of compiler.
  --no-framework:
        Do not reference the .NET Framework assemblies by default.
  --sscli:
        Force the compiler to look use the installation
        of the SSCLI found on the path rather than an installed Microsoft CLI.
        Also produces debug information in the SSCLI format.
  --max-errors : 
  --generate-filter-blocks: Generate filter blocks to allow first-chance 
        exception catching for non-matching exceptions
  --stamps: 
  --ranges: 
  --terms: 
  --termsfile: 
  --ilfiles: 
  --times: 
  --detuple : 
  --tlr : 
  --tlrlift : 
  --no-env: 
  --parse-only: 
  --typecheck-only: 
  --ast: 
  --tokenize: 
  --testInteractionParser: 
  --light: 
  --lightoff: 
  --inline-threshold : 
  --extra-optimization-loops : 
  --generics:
  --no-generics:
        Fine grained control over whether to produce code for a .NET CLR
        that supports generics.
  --all-tailcalls:
  --no-tailcalls:
        Fine grained control over whether to emit tailcall annotations.
  --closures-as-virtuals:
        Fine grained control over the implementaion of closures.
  --multi-entrypoint-closures: