Usage: ocamlopt <options> <files>
Options are:
-fPIC Generate position-independent machine code (default)
-fno-PIC Generate position-dependent machine code
-a Build a library
-alert <list> Enable or disable alerts according to <list>:
+<alertname> enable alert <alertname>
-<alertname> disable alert <alertname>
++<alertname> treat <alertname> as fatal error
--<alertname> treat <alertname> as non-fatal
@<alertname> enable <alertname> and treat it as fatal error
<alertname> can be 'all' to refer to all alert names
-absname Show absolute filenames in error messages
-afl-instrument Enable instrumentation for afl-fuzz
-afl-inst-ratio Configure percentage of branches instrumented
(advanced, see afl-fuzz docs for AFL_INST_RATIO)
-annot (deprecated) Save information in <filename>.annot
-bin-annot Save typedtree in <filename>.cmt
-inline-branch-factor <n>|<round>=<n>[,...] Estimate the probability of a branch being cold as 1/(1+n) (used for inlining) (default 0.10)
-c Compile only (do not link)
-cc <command> Use <command> as the C compiler and linker
-cclib <opt> Pass option <opt> to the C linker
-ccopt <opt> Pass option <opt> to the C compiler and linker
-clambda-checks Instrument clambda code with closure and field access checks (for debugging the compiler)
-Oclassic Make inlining decisions at function definition time rather than at the call site (replicates previous behaviour of the compiler)
-color {auto|always|never} Enable or disable colors in compiler messages
The following settings are supported:
auto use heuristics to enable colors only if supported
always enable colors
never disable colors
The default setting is 'auto', and the current heuristic
checks that the TERM environment variable exists and is
not empty or "dumb", and that isatty(stderr) holds.
If the option is not specified, these setting can alternatively
be set through the OCAML_COLOR environment variable.
-error-style {contextual|short} Control the way error messages and warnings are printed
The following settings are supported:
short only print the error and its location
contextual like "short", but also display the source code
snippet corresponding to the location of the error
The default setting is 'contextual'.
If the option is not specified, these setting can alternatively
be set through the OCAML_ERROR_STYLE environment variable.
-compact Optimize code size rather than speed
-config Print configuration values and exit
-config-var Print the value of a configuration variable, without a newline, and exit
(print nothing and exit with error value if the variable does not exist)
-dtypes (deprecated) same as -annot
-for-pack <ident> Generate code that can later be `packed' with
ocamlopt -pack -o <ident>.cmx
-g Record debugging information for exception backtrace
-function-sections Generate each function in a separate section if target supports it
-stop-after {parsing|typing|scheduling|emit} Stop after the given compilation pass.
-save-ir-after {scheduling} Save intermediate representation after the given compilation pass(may be specified more than once).
-i Print inferred interface
-I <dir> Add <dir> to the list of include directories
-impl <file> Compile <file> as a .ml file
-inline <n>|<round>=<n>[,...] Aggressiveness of inlining (default 1.25, higher numbers mean more aggressive)
-inline-toplevel <n>|<round>=<n>[,...] Aggressiveness of inlining at toplevel (higher numbers mean more aggressive)
-inline-alloc-cost <n>|<round>=<n>[,...] The cost of not removing an allocation during inlining (default 7, higher numbers more costly)
-inline-branch-cost <n>|<round>=<n>[,...] The cost of not removing a conditional during inlining (default 5, higher numbers more costly)
-inline-call-cost <n>|<round>=<n>[,...] The cost of not removing a call during inlining (default 5, higher numbers more costly)
-inline-prim-cost <n>|<round>=<n>[,...] The cost of not removing a primitive during inlining (default 3, higher numbers more costly)
-inline-indirect-cost <n>|<round>=<n>[,...] The cost of not removing an indirect call during inlining (default 4, higher numbers more costly)
-inline-lifting-benefit <n>|<round>=<n>[,...] The benefit of lifting definitions to toplevel during inlining (default 1300, higher numbers more beneficial)
-inlining-report Emit `.<round>.inlining' file(s) (one per round) showing the inliner's decisions
-insn-sched Run the instruction scheduling pass (default)
-intf <file> Compile <file> as a .mli file
-intf-suffix <string> Suffix for interface files (default: .mli)
-keep-docs Keep documentation strings in .cmi files
-no-keep-docs Do not keep documentation strings in .cmi files (default)
-keep-locs Keep locations in .cmi files (default)
-no-keep-locs Do not keep locations in .cmi files
-labels Use commuting label mode
-linkall Link all modules, even unused ones
-inline-max-depth <n>|<round>=<n>[,...] Maximum depth of search for inlining opportunities inside inlined functions (default 1)
-alias-deps Do record dependencies for module aliases
-no-alias-deps Do not record dependencies for module aliases
-linscan Use the linear scan register allocator
-app-funct Activate applicative functors
-no-app-funct Deactivate applicative functors
-no-float-const-prop Deactivate constant propagation for floating-point operations
-noassert Do not compile assertion checks
-noautolink Do not automatically link C libraries specified in .cmxa files
-nodynlink Enable optimizations for code that will not be dynlinked
-no-insn-sched Do not run the instruction scheduling pass
-nolabels Ignore non-optional labels in types
-nostdlib Do not add default directory to the list of include directories
-nopervasives (undocumented)
-no-unbox-free-vars-of-closures Do not unbox variables that will appear inside function closures
-no-unbox-specialised-args Do not unbox arguments to which functions have been specialised
-o <file> Set output file name to <file>
-O2 Apply increased optimization for speed
-O3 Apply aggressive optimization for speed (may significantly increase code size and compilation time)
-opaque Does not generate cross-module optimization information
(reduces necessary recompilation on module change)
-open <module> Opens the module <module> before typing
-output-obj Output an object file instead of an executable
-output-complete-obj Output an object file, including runtime, instead of an executable
-p (no longer supported)
-pack Package the given .cmx files into one .cmx
-plugin <plugin> (no longer supported)
-pp <command> Pipe sources through preprocessor <command>
-ppx <command> Pipe abstract syntax trees through preprocessor <command>
-principal Check principality of type inference
-no-principal Do not check principality of type inference (default)
-rectypes Allow arbitrary recursive types
-no-rectypes Do not allow arbitrary recursive types (default)
-remove-unused-arguments Remove unused function arguments
-rounds <n> Repeat tree optimization and inlining phases this many times (default 1). Rounds are numbered starting from zero.
-runtime-variant <str> Use the <str> variant of the run-time system
-with-runtime Include the runtime system in the generated program (default)
-without-runtime Do not include the runtime system in the generated program.
-S Keep intermediate assembly file
-safe-string (was set when configuring the compiler)
-shared Produce a dynlinkable plugin
-short-paths Shorten paths in types
-strict-sequence Left-hand part of a sequence must have type unit
-no-strict-sequence Left-hand part of a sequence need not have type unit (default)
-strict-formats Reject invalid formats accepted by legacy implementations
(Warning: Invalid formats may behave differently from
previous OCaml versions, and will become always-rejected
in future OCaml versions. You should always use this flag
to detect invalid formats so you can fix them.)
-no-strict-formats Accept invalid formats accepted by legacy implementations (default)
(Warning: Invalid formats may behave differently from
previous OCaml versions, and will become always-rejected
in future OCaml versions. You should never use this flag
and instead fix invalid formats.)
-thread (deprecated) same as -I +threads
-unbox-closures Pass free variables via specialised arguments rather than closures
-unbox-closures-factor <n > 0> Scale the size threshold above which unbox-closures will slow down indirect calls rather than duplicating a function (default 10)
-inline-max-unroll <n>|<round>=<n>[,...] Unroll recursive functions at most this many times (default 0)
-unboxed-types unannotated unboxable types will be unboxed
-no-unboxed-types unannotated unboxable types will not be unboxed (default)
-unsafe Do not compile bounds checking on array and string access
-unsafe-string (option not available)
-v Print compiler version and location of standard library and exit
-verbose Print calls to external commands
-version Print version and exit
--version Print version and exit
-vnum Print version number and exit
-w <list> Enable or disable warnings according to <list>:
+<spec> enable warnings in <spec>
-<spec> disable warnings in <spec>
@<spec> enable warnings in <spec> and treat them as errors
<spec> can be:
<num> a single warning number
<num1>..<num2> a range of consecutive warning numbers
<letter> a predefined set
default setting is "+a-4-7-9-27-29-30-32..42-44-45-48-50-60-66..70"
-warn-error <list> Enable or disable error status for warnings according
to <list>. See option -w for the syntax of <list>.
Default setting is "-a+31"
-warn-help Show description of warning numbers
-where Print location of standard library and exit
- <file> Treat <file> as a file name (even if it starts with `-')
-match-context-rows <n> (advanced, see manual section 11.2.)
-dno-unique-ids (undocumented)
-dunique-ids (undocumented)
-dno-locations (undocumented)
-dlocations (undocumented)
-dsource (undocumented)
-dparsetree (undocumented)
-dtypedtree (undocumented)
-dshape (undocumented)
-drawlambda (undocumented)
-dlambda (undocumented)
-drawclambda (undocumented)
-dclambda (undocumented)
-dcmm-invariants Extra sanity checks on Cmm
-dflambda Print Flambda terms
-drawflambda Print Flambda terms after closure conversion
-dflambda-invariants Check Flambda invariants around each pass
-dflambda-no-invariants Do not Check Flambda invariants around each pass
-dflambda-let <stamp> Print when the given Flambda [Let] is created
-dflambda-verbose Print Flambda terms including around each pass
-dcmm (undocumented)
-dsel (undocumented)
-dcombine (undocumented)
-dcse (undocumented)
-dlive (undocumented)
-dspill (undocumented)
-dsplit (undocumented)
-dinterf (undocumented)
-dprefer (undocumented)
-dalloc (undocumented)
-dreload (undocumented)
-dscheduling (undocumented)
-dlinear (undocumented)
-dinterval (undocumented)
-dstartup (undocumented)
-dtimings Print timings information for each pass
-dprofile Print performance information for each pass
The columns are: time alloc top-heap absolute-top-heap.
-dump-into-file dump output like -dlambda into <target>.dump
-dump-dir <dir> dump output like -dlambda into <dir>/<target>.dump
-dump-pass Record transformations performed by these passes:
unbox-closures unbox-specialised-args unbox-free-vars-of-closures
remove-free-vars-equal-to-args remove-unused-arguments unused-arguments
-args <file> Read additional newline-terminated command line arguments
from <file>
-args0 <file> Read additional null character terminated command line arguments
from <file>
-depend <options> Compute dependencies (use 'ocamlopt -depend -help' for details)
-help Display this list of options
--help Display this list of options
Options (154)
| Option | Description | Source |
|---|---|---|
-fPIC | Generate position-independent machine code (default) | help + man |
-fno-PIC | Generate position-dependent machine code. | help + man |
-a | Build a library (.cmxa/.a file) with the object files (.cmx/.o files) given on the command line, instead of linking them into an executable file. | help + man |
-alert list | Enable or disable alerts according to <list>: +<alertname> enable alert <alertname> | help |
-absname | Show absolute filenames in error messages. | help + man |
-annot | (deprecated) Save information in <filename>.annot | help + man |
-bin-annot | Dump detailed information about the compilation (types, bindings, tail-calls, etc) in binary format. | help + man |
-inline-branch-factor n>|<round>=<n | Estimate the probability of a branch being cold as 1/(1+n) (used for inlining) (default 0.10) | help |
-c | Compile only (do not link) | help + man |
-cc command | Use <command> as the C compiler and linker | help |
-cclib opt | Pass option <opt> to the C linker | help |
-ccopt opt | Pass option <opt> to the C compiler and linker | help |
-clambda-checks | Instrument clambda code with closure and field access checks (for debugging the compiler) | help |
-Oclassic | Make inlining decisions at function definition time rather than at the call site (replicates previous behaviour of the compiler) | help |
-color auto|always|never | Enable or disable colors in compiler messages The following settings are supported: auto use heuristics to enable colors only if supported always enable colors never disable colors The default… | help |
-error-style contextual|short | Control the way error messages and warnings are printed The following settings are supported: short only print the error and its location contextual like "short", but also display the source code… | help |
-compact | Optimize the produced code for space rather than for time. | help + man |
-config | Print the version number of ocamlopt(1) and a detailed summary of its configuration, then exit. | help + man |
-config-var | Print the value of a configuration variable, without a newline, and exit (print nothing and exit with error value if the variable does not exist) | help + man |
-dtypes | (deprecated) same as -annot | help |
-for-pack ident | Generate code that can later be `packed' with ocamlopt -pack -o <ident>.cmx | help |
-g | Add debugging information while compiling and linking. | help + man |
-function-sections | Generate each function in a separate section if target supports it | help |
-i | Cause the compiler to print all defined names (with their inferred types or their definitions) when compiling an implementation (.ml file). | help + man |
-I dir | Add <dir> to the list of include directories | help |
-impl file | Compile <file> as a .ml file | help |
-inline n>|<round>=<n | Aggressiveness of inlining (default 1.25, higher numbers mean more aggressive) | help |
-inline-toplevel n>|<round>=<n | Aggressiveness of inlining at toplevel (higher numbers mean more aggressive) | help |
-inline-alloc-cost n>|<round>=<n | The cost of not removing an allocation during inlining (default 7, higher numbers more costly) | help |
-inline-branch-cost n>|<round>=<n | The cost of not removing a conditional during inlining (default 5, higher numbers more costly) | help |
-inline-call-cost n>|<round>=<n | The cost of not removing a call during inlining (default 5, higher numbers more costly) | help |
-inline-prim-cost n>|<round>=<n | The cost of not removing a primitive during inlining (default 3, higher numbers more costly) | help |
-inline-indirect-cost n>|<round>=<n | The cost of not removing an indirect call during inlining (default 4, higher numbers more costly) | help |
-inline-lifting-benefit n>|<round>=<n | The benefit of lifting definitions to toplevel during inlining (default 1300, higher numbers more beneficial) | help |
-inlining-report | Emit `.<round>.inlining' file(s) (one per round) showing the inliner's decisions | help |
-insn-sched | Enables the instruction scheduling pass in the compiler backend. | help + man |
-intf file | Compile <file> as a .mli file | help |
-intf-suffix string | Suffix for interface files (default: .mli) | help |
-keep-docs | Keep documentation strings in generated .cmi files. | help + man |
-no-keep-docs | Do not keep documentation strings in .cmi files (default) | help |
-keep-locs | Keep locations in generated .cmi files. | help + man |
-no-keep-locs | Do not keep locations in .cmi files | help |
-labels | Labels are not ignored in types, labels may be used in applications, and labelled parameters can be given in any order. | help + man |
-linkall | Force all modules contained in libraries to be linked in. | help + man |
-inline-max-depth n>|<round>=<n | Maximum depth of search for inlining opportunities inside inlined functions (default 1) | help |
-alias-deps | Do record dependencies for module aliases | help |
-no-alias-deps | Do not record dependencies for module aliases. | help + man |
-linscan | Use the linear scan register allocator | help + man |
-app-funct | Activate applicative functors | help |
-no-app-funct | Deactivates the applicative behaviour of functors. | help + man |
-no-float-const-prop | Deactivate constant propagation for floating-point operations | help |
-noassert | Do not compile assertion checks. | help + man |
-noautolink | When linking .cmxa libraries, ignore -cclib and -ccopt options potentially contained in the libraries (if these options were given when building the libraries). | help + man |
-nodynlink | Allow the compiler to use some optimizations that are valid only for code that is never dynlinked. | help + man |
-no-insn-sched | Disables the instruction scheduling pass in the compiler backend. | help + man |
-nolabels | Ignore non-optional labels in types. | help + man |
-nostdlib | Do not automatically add the standard library directory to the list of directories searched for compiled interface files (.cmi), compiled object code files (.cmx), and libraries (.cmxa). | help + man |
-nopervasives | (undocumented) | help |
-no-unbox-free-vars-of-closures | Do not unbox variables that will appear inside function closures | help |
-no-unbox-specialised-args | Do not unbox arguments to which functions have been specialised | help |
-o file | Set output file name to <file> | help |
-O2 | Apply increased optimization for speed | help |
-O3 | Apply aggressive optimization for speed (may significantly increase code size and compilation time) | help |
-opaque | When compiling a .mli interface file, this has the same effect as the -opaque option of the bytecode compiler. | help + man |
-open module | Opens the module <module> before typing | help |
-output-obj | Cause the linker to produce a C object file instead of an executable file. | help + man |
-output-complete-obj | Output an object file, including runtime, instead of an executable | help |
-p | (no longer supported) | help |
-pack | Build an object file (.cmx and .o files) and its associated compiled interface (.cmi) that combines the .cmx object files given on the command line, making them appear as sub-modules of the output… | help + man |
-plugin plugin | (no longer supported) | help |
-pp command | Pipe sources through preprocessor <command> | help |
-ppx command | Pipe abstract syntax trees through preprocessor <command> | help |
-principal | Check information path during type-checking, to make sure that all types are derived in a principal way. | help + man |
-no-principal | Do not check principality of type inference (default) | help |
-rectypes | Allow arbitrary recursive types during type-checking. | help + man |
-no-rectypes | Do not allow arbitrary recursive types (default) | help |
-remove-unused-arguments | Remove unused function arguments | help |
-rounds n | Repeat tree optimization and inlining phases this many times (default 1). | help |
-runtime-variant str | Use the <str> variant of the run-time system | help |
-S | Keep the assembly code produced during the compilation. | help + man |
-safe-string | Enforce the separation between types string and bytes, thereby making strings read-only. | help + man |
-shared | Build a plugin (usually .cmxs) that can be dynamically loaded with the Dynlink module. | help + man |
-short-paths | When a type is visible under several module-paths, use the shortest one when printing the type's name in inferred interfaces and error and warning messages. | help + man |
-strict-sequence | The left-hand part of a sequence must have type unit. | help + man |
-no-strict-sequence | Left-hand part of a sequence need not have type unit (default) | help |
-strict-formats | Reject invalid formats accepted by legacy implementations (Warning: Invalid formats may behave differently from previous OCaml versions, and will become always-rejected in future OCaml versions. | help |
-no-strict-formats | Accept invalid formats accepted by legacy implementations (default) (Warning: Invalid formats may behave differently from previous OCaml versions, and will become always-rejected in future OCaml… | help |
-thread | (deprecated) same as -I +threads | help |
-unbox-closures | Pass free variables via specialised arguments rather than closures | help |
-unbox-closures-factor n | Scale the size threshold above which unbox-closures will slow down indirect calls rather than duplicating a function (default 10) | help |
-inline-max-unroll n>|<round>=<n | Unroll recursive functions at most this many times (default 0) | help |
-unboxed-types | When a type is unboxable (i.e. a record with a single argument or a concrete datatype with a single constructor of one argument) it will be unboxed unless annotated with [@@ocaml.boxed]. | help + man |
-no-unboxed-types | When a type is unboxable it will be boxed unless annotated with [@@ocaml.unboxed]. | help + man |
-unsafe | Turn bound checking off for array and string accesses (the v.(i)ands.[i] constructs). | help + man |
-unsafe-string | Identify the types string and bytes, thereby making strings writable. | help + man |
-v | Print the version number of the compiler and the location of the standard library directory, then exit. | help + man |
-verbose | Print all external commands before they are executed, in particular invocations of the assembler, C compiler, and linker. | help + man |
-version | Print version and exit | help |
--version | Print version and exit | help |
-vnum | Print version number and exit | help |
-w list | Enable or disable warnings according to <list>: +<spec> enable warnings in <spec> | help |
-warn-error list | Enable or disable error status for warnings according to <list>. | help |
-warn-help | Show the description of all available warning numbers. | help + man |
-where | Print the location of the standard library, then exit. | help + man |
-match-context-rows n | Set number of rows of context used during pattern matching compilation. | help + man |
-dno-unique-ids | (undocumented) | help |
-dunique-ids | (undocumented) | help |
-dno-locations | (undocumented) | help |
-dlocations | (undocumented) | help |
-dsource | (undocumented) | help |
-dparsetree | (undocumented) | help |
-dtypedtree | (undocumented) | help |
-dshape | (undocumented) | help |
-drawlambda | (undocumented) | help |
-dlambda | (undocumented) | help |
-drawclambda | (undocumented) | help |
-dclambda | (undocumented) | help |
-dcmm-invariants | Extra sanity checks on Cmm | help |
-dflambda | Print Flambda terms | help |
-drawflambda | Print Flambda terms after closure conversion | help |
-dflambda-invariants | Check Flambda invariants around each pass | help |
-dflambda-no-invariants | Do not Check Flambda invariants around each pass | help |
-dflambda-let stamp | Print when the given Flambda [Let] is created | help |
-dflambda-verbose | Print Flambda terms including around each pass | help |
-dcmm | (undocumented) | help |
-dsel | (undocumented) | help |
-dcombine | (undocumented) | help |
-dcse | (undocumented) | help |
-dlive | (undocumented) | help |
-dspill | (undocumented) | help |
-dsplit | (undocumented) | help |
-dinterf | (undocumented) | help |
-dprefer | (undocumented) | help |
-dalloc | (undocumented) | help |
-dreload | (undocumented) | help |
-dscheduling | (undocumented) | help |
-dlinear | (undocumented) | help |
-dinterval | (undocumented) | help |
-dstartup | (undocumented) | help |
-dtimings | Print timings information for each pass | help |
-dprofile | Print performance information for each pass The columns are: time alloc top-heap absolute-top-heap. | help |
-dump-into-file | dump output like -dlambda into <target>.dump | help |
-dump-pass | Record transformations performed by these passes: unbox-closures unbox-specialised-args unbox-free-vars-of-closures remove-free-vars-equal-to-args remove-unused-arguments unused-arguments | help |
-help | Display this list of options | help |
--help | Display this list of options | help |
-with-runtime | Include the runtime system in the generated program. (in the manual page but not in --help) | man |
-without-runtime | The compiler does not include the runtime system (nor a reference to it) in the generated program; (in the manual page but not in --help) | man |
-ffast-math | Use the IA32 instructions to compute trigonometric and exponential functions, instead of calling the corresponding library routines. (in the manual page but not in --help) | man |
-flarge-toc | Enables the PowerPC large model allowing the TOC (table of contents) to be arbitrarily large. (in the manual page but not in --help) | man |
-fsmall-toc | Enables the PowerPC small model allowing the TOC to be up to 64 kbytes per compilation unit. (in the manual page but not in --help) | man |
-farch armv4|armv5|armv5te|armv6|armv6t2|armv7 | Select the ARM target architecture (in the manual page but not in --help) | man |
-ffpu soft|vfpv2|vfpv3-d16|vfpv3 | Select the floating-point hardware (in the manual page but not in --help) | man |
-fthumb | Enable Thumb/Thumb-2 code generation (in the manual page but not in --help) | man |
-fno-thumb | Disable Thumb/Thumb-2 code generation (in the manual page but not in --help) | man |