Partager via


Compiler Options (F#)

This topic describes compiler command-line options for the F# compiler, fsc.exe. The compilation environment can also be controlled by setting the project properties.

Compiler Options Listed Alphabetically

The following table shows compiler options listed alphabetically. Some of the F# compiler options are similar to the C# compiler options. If that is the case, a link to the C# compiler options topic is provided.

Compiler Option

Description

-a<output-filename>

Generates a library and specifies its filename. This option is a short form of --target:library<filename>.

--baseaddress:<string>

Specifies the base address of the library to be built.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /baseaddress (C# Compiler Options).

--codepage:<int>

Specifies the codepage used to read source files.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /codepage (C# Compiler Options).

--consolecolors

Specifies that errors and warnings use color-coded text on the console.

--crossoptimize[+|-]

Enables or disables cross-module optimizations.

--delaysign[+|-]

Delay-signs the assembly using only the public portion of the strong name key.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /delaysign (C# Compiler Options).

--checked[+|-]

Enables or disables the generation of overflow checks.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /checked (C# Compiler Options).

--debug[+|-]

-g[+|-]

--debug:[full|pdbonly]

-g: [full|pdbonly]

Enables or disables the generation of debug information, or specifies the type of debug information to generate. The default is full, which allows attaching to a running program. Choose pdbonly to get limited debugging information stored in a pdb (program database) file.

Equivalent to the C# compiler option of the same name. For more information, see

/debug (C# Compiler Options).

--define:<string>

-d:<string>

Defines a symbol for use in conditional compilation.

--doc:<xmldoc-filename>

Instructs the compiler to generate XML documentation comments to the file specified. For more information, see XML Documentation (F#).

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /doc (C# Compiler Options).

--fullpaths

Instructs the compiler to generate fully qualified paths.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /fullpaths (C# Compiler Options).

--help

-?

Displays usage information, including a brief description of all the compiler options.

--highentropyva[+|-]

Enable or disable high-entropy address space layout randomization (ASLR), an enhanced security feature. The OS randomizes the locations in memory where infrastructure for applications (such as the stack and heap) are loaded. If you enable this option, operating systems can use this randomization to use the full 64-bit address-space on a 64-bit machine.

--keycontainer:<string>

Specifies a strong name key container.

--keyfile:<filename>

Specifies the name of a public key file for signing the generated assembly.

--lib:<folder-name>

-I:<folder-name>

Specifies a directory to be searched for assemblies that are referenced.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /lib (C# Compiler Options).

--linkresource:<resource-info>

Links a specified resource to the assembly. The format of resource-info is filename[,name[,public|private]]

Linking a single resource with this option is an alternative to embedding an entire resource file with the --resource option.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /linkresource (C# Compiler Options).

--mlcompatibility

Ignores warnings that appear when you use features that are designed for compatibility with other versions of ML.

--noframework

Disables the default reference to the .NET Framework assembly.

--nointerfacedata

Instructs the compiler to omit the resource it normally adds to an assembly that includes F#-specific metadata.

--nologo

Doesn't show the banner text when launching the compiler.

--nooptimizationdata

Instructs the compiler to only include optimization essential for implementing inlined constructs. Inhibits cross-module inlining but improves binary compatibility.

--nowin32manifest

Instructs the compiler to omit the default Win32 manifest.

--nowarn:<int-list>

Disables specific warnings listed by number. Separate each warning number by a comma. You can discover the warning number for any warning from the compilation output.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /nowarn (C# Compiler Options).

--optimize[+|-] [<string-list>]

-O[+|-] [<string-list>]

Enables or disables optimizations. Some optimization options can be disabled or enabled selectively by listing them. These are: nojitoptimize, nojittracking, nolocaloptimize, nocrossoptimize, notailcalls.

--out:<output-filename>

-o:<output-filename>

Specifies the name of the compiled assembly or module.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /out (C# Compiler Options).

--pdb:<pdb-filename>

Names the output debug PDB (program database) file. This option only applies when --debug is also enabled.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /pdb (C# Compiler Options).

--platform:<platform-name>

Specifies that the generated code will only run on the specified platform (x86, Itanium, or x64), or, if the platform-name anycpu is chosen, specifies that the generated code can run on any platform.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /platform (C# Compiler Options).

--quotations-debug

Specifies that extra debugging information should be emitted for expressions that are derived from F# quotation literals and reflected definitions. The debug information is added to the custom attributes of an F# expression tree node. See Code Quotations (F#) and Expr.CustomAttributes.

--reference:<assembly-filename>

-r <assembly-filename>

Makes code from an F# or .NET Framework assembly available to the code being compiled.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /reference (C# Compiler Options).

--resource:<resource-filename>

Embeds a managed resource file into the generated assembly.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /resource (C# Compiler Options).

--sig:<signature-filename>

Generates a signature file based on the generated assembly. For more information about signature files, see Signatures (F#).

--simpleresolution

Specifies that assembly references should be resolved using directory-based Mono rules rather than MSBuild resolution. The default is to use MSBuild resolution except when running under Mono.

--standalone

Specifies to produce an assembly that contains all of its dependencies so that it runs by itself without the need for additional assemblies, such as the F# library.

--staticlink:<assembly-name>

Statically links the given assembly and all referenced DLLs that depend on this assembly. Use the assembly name, not the DLL name.

--subsystemversion

Specifies the version of the OS subsystem to be used by the generated executable. Use 6.02 for Windows 8, 6.01 for Windows 7, 6.00 for Windows Vista. This option only applies to executables, not DLLs, and need only be used if your application depends on specific security features available only on certain versions of the OS. If this option is used, and a user attempts to execute your application on a lower version of the OS, it will fail with an error message.

--tailcalls[+|-]

Enables or disables the use of the tail IL instruction, which causes the stack frame to be reused for tail recursive functions. This option is enabled by default.

--target:[exe | winexe | library | module ] <output-filename>

Specifies the type and file name of the generated compiled code.

  • exe means a console application.

  • winexe means a Windows application, which differs from the console application in that it does not have standard input/output streams (stdin, stdout, and stderr) defined.

  • library is an assembly without an entry point.

  • module is a .NET Framework module (.netmodule), which can later be combined with other modules into an assembly.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /target (C# Compiler Options).

--times

Displays timing information for compilation.

--utf8output

Enables printing compiler output in the UTF-8 encoding.

--warn:<warning-level>

Sets a warning level (0 to 5). The default level is 3. Each warning is given a level based on its severity. Level 5 gives more, but less severe, warnings than level 1.

Level 5 warnings are: 21 (recursive use checked at runtime), 22 (let rec evaluated out of order), 45 (full abstraction), and 52 (defensive copy). All other warnings are level 2.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /warn (C# Compiler Options).

--warnon:<int-list>

Enable specific warnings that might be off by default or disabled by another command line option. In F# 3.0, only the 1182 (unused variables) warning is off by default.

--warnaserror[+|-] [<int-list>]

Enables or disables the option to report warnings as errors. You can provide specific warning numbers to be disabled or enabled. Options later in the command line override options earlier in the command line. For example, to specify the warnings that you don't want reported as errors, specify --warnaserror+ --warnaserror-:<int-list>.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /warnaserror (C# Compiler Options).

--win32manifest:manifest-filename

Adds a Win32 manifest file to the compilation. This compiler option is equivalent to the C# compiler option of the same name. For more information, see /win32manifest (C# Compiler Options).

--win32res:resource-filename

Adds a Win32 resource file to the compilation.

This compiler option is equivalent to the C# compiler option of the same name. For more information, see /win32res (C# Compiler Options).

Title

Description

F# Interactive Options

Describes command-line options supported by the F# interpreter, fsi.exe.

Project Properties Reference

Describes the UI for projects, including project property pages that provide build options.