OS Manuals

/usr/bin/ocamlopt-4

The core OCaml 4 system: compilers, runtime system, base libraries

From ocaml-4 4.14.5-r0 (enterprise-packages), captured 2026-11-08 by running ocamlopt-4 --help (exit 0). permalink

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)
OptionDescriptionSource
-fPICGenerate position-independent machine code (default)help + man
-fno-PICGenerate position-dependent machine code.help + man
-aBuild 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 listEnable or disable alerts according to <list>: +<alertname> enable alert <alertname>help
-absnameShow absolute filenames in error messages.help + man
-annot(deprecated) Save information in <filename>.annothelp + man
-bin-annotDump detailed information about the compilation (types, bindings, tail-calls, etc) in binary format.help + man
-inline-branch-factor n>|<round>=<nEstimate the probability of a branch being cold as 1/(1+n) (used for inlining) (default 0.10)help
-cCompile only (do not link)help + man
-cc commandUse <command> as the C compiler and linkerhelp
-cclib optPass option <opt> to the C linkerhelp
-ccopt optPass option <opt> to the C compiler and linkerhelp
-clambda-checksInstrument clambda code with closure and field access checks (for debugging the compiler)help
-OclassicMake inlining decisions at function definition time rather than at the call site (replicates previous behaviour of the compiler)help
-color auto|always|neverEnable 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|shortControl 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
-compactOptimize the produced code for space rather than for time.help + man
-configPrint the version number of ocamlopt(1) and a detailed summary of its configuration, then exit.help + man
-config-varPrint 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 -annothelp
-for-pack identGenerate code that can later be `packed' with ocamlopt -pack -o <ident>.cmxhelp
-gAdd debugging information while compiling and linking.help + man
-function-sectionsGenerate each function in a separate section if target supports ithelp
-iCause the compiler to print all defined names (with their inferred types or their definitions) when compiling an implementation (.ml file).help + man
-I dirAdd <dir> to the list of include directorieshelp
-impl fileCompile <file> as a .ml filehelp
-inline n>|<round>=<nAggressiveness of inlining (default 1.25, higher numbers mean more aggressive)help
-inline-toplevel n>|<round>=<nAggressiveness of inlining at toplevel (higher numbers mean more aggressive)help
-inline-alloc-cost n>|<round>=<nThe cost of not removing an allocation during inlining (default 7, higher numbers more costly)help
-inline-branch-cost n>|<round>=<nThe cost of not removing a conditional during inlining (default 5, higher numbers more costly)help
-inline-call-cost n>|<round>=<nThe cost of not removing a call during inlining (default 5, higher numbers more costly)help
-inline-prim-cost n>|<round>=<nThe cost of not removing a primitive during inlining (default 3, higher numbers more costly)help
-inline-indirect-cost n>|<round>=<nThe cost of not removing an indirect call during inlining (default 4, higher numbers more costly)help
-inline-lifting-benefit n>|<round>=<nThe benefit of lifting definitions to toplevel during inlining (default 1300, higher numbers more beneficial)help
-inlining-reportEmit `.<round>.inlining' file(s) (one per round) showing the inliner's decisionshelp
-insn-schedEnables the instruction scheduling pass in the compiler backend.help + man
-intf fileCompile <file> as a .mli filehelp
-intf-suffix stringSuffix for interface files (default: .mli)help
-keep-docsKeep documentation strings in generated .cmi files.help + man
-no-keep-docsDo not keep documentation strings in .cmi files (default)help
-keep-locsKeep locations in generated .cmi files.help + man
-no-keep-locsDo not keep locations in .cmi fileshelp
-labelsLabels are not ignored in types, labels may be used in applications, and labelled parameters can be given in any order.help + man
-linkallForce all modules contained in libraries to be linked in.help + man
-inline-max-depth n>|<round>=<nMaximum depth of search for inlining opportunities inside inlined functions (default 1)help
-alias-depsDo record dependencies for module aliaseshelp
-no-alias-depsDo not record dependencies for module aliases.help + man
-linscanUse the linear scan register allocatorhelp + man
-app-functActivate applicative functorshelp
-no-app-functDeactivates the applicative behaviour of functors.help + man
-no-float-const-propDeactivate constant propagation for floating-point operationshelp
-noassertDo not compile assertion checks.help + man
-noautolinkWhen linking .cmxa libraries, ignore -cclib and -ccopt options potentially contained in the libraries (if these options were given when building the libraries).help + man
-nodynlinkAllow the compiler to use some optimizations that are valid only for code that is never dynlinked.help + man
-no-insn-schedDisables the instruction scheduling pass in the compiler backend.help + man
-nolabelsIgnore non-optional labels in types.help + man
-nostdlibDo 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-closuresDo not unbox variables that will appear inside function closureshelp
-no-unbox-specialised-argsDo not unbox arguments to which functions have been specialisedhelp
-o fileSet output file name to <file>help
-O2Apply increased optimization for speedhelp
-O3Apply aggressive optimization for speed (may significantly increase code size and compilation time)help
-opaqueWhen compiling a .mli interface file, this has the same effect as the -opaque option of the bytecode compiler.help + man
-open moduleOpens the module <module> before typinghelp
-output-objCause the linker to produce a C object file instead of an executable file.help + man
-output-complete-objOutput an object file, including runtime, instead of an executablehelp
-p(no longer supported)help
-packBuild 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 commandPipe sources through preprocessor <command>help
-ppx commandPipe abstract syntax trees through preprocessor <command>help
-principalCheck information path during type-checking, to make sure that all types are derived in a principal way.help + man
-no-principalDo not check principality of type inference (default)help
-rectypesAllow arbitrary recursive types during type-checking.help + man
-no-rectypesDo not allow arbitrary recursive types (default)help
-remove-unused-argumentsRemove unused function argumentshelp
-rounds nRepeat tree optimization and inlining phases this many times (default 1).help
-runtime-variant strUse the <str> variant of the run-time systemhelp
-SKeep the assembly code produced during the compilation.help + man
-safe-stringEnforce the separation between types string and bytes, thereby making strings read-only.help + man
-sharedBuild a plugin (usually .cmxs) that can be dynamically loaded with the Dynlink module.help + man
-short-pathsWhen 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-sequenceThe left-hand part of a sequence must have type unit.help + man
-no-strict-sequenceLeft-hand part of a sequence need not have type unit (default)help
-strict-formatsReject 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-formatsAccept 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 +threadshelp
-unbox-closuresPass free variables via specialised arguments rather than closureshelp
-unbox-closures-factor nScale 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>=<nUnroll recursive functions at most this many times (default 0)help
-unboxed-typesWhen 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-typesWhen a type is unboxable it will be boxed unless annotated with [@@ocaml.unboxed].help + man
-unsafeTurn bound checking off for array and string accesses (the v.(i)ands.[i] constructs).help + man
-unsafe-stringIdentify the types string and bytes, thereby making strings writable.help + man
-vPrint the version number of the compiler and the location of the standard library directory, then exit.help + man
-verbosePrint all external commands before they are executed, in particular invocations of the assembler, C compiler, and linker.help + man
-versionPrint version and exithelp
--versionPrint version and exithelp
-vnumPrint version number and exithelp
-w listEnable or disable warnings according to <list>: +<spec> enable warnings in <spec>help
-warn-error listEnable or disable error status for warnings according to <list>.help
-warn-helpShow the description of all available warning numbers.help + man
-wherePrint the location of the standard library, then exit.help + man
-match-context-rows nSet 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-invariantsExtra sanity checks on Cmmhelp
-dflambdaPrint Flambda termshelp
-drawflambdaPrint Flambda terms after closure conversionhelp
-dflambda-invariantsCheck Flambda invariants around each passhelp
-dflambda-no-invariantsDo not Check Flambda invariants around each passhelp
-dflambda-let stampPrint when the given Flambda [Let] is createdhelp
-dflambda-verbosePrint Flambda terms including around each passhelp
-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
-dtimingsPrint timings information for each passhelp
-dprofilePrint performance information for each pass The columns are: time alloc top-heap absolute-top-heap.help
-dump-into-filedump output like -dlambda into <target>.dumphelp
-dump-passRecord 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-argumentshelp
-helpDisplay this list of optionshelp
--helpDisplay this list of optionshelp
-with-runtimeInclude the runtime system in the generated program. (in the manual page but not in --help)man
-without-runtimeThe 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-mathUse 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-tocEnables the PowerPC large model allowing the TOC (table of contents) to be arbitrarily large. (in the manual page but not in --help)man
-fsmall-tocEnables 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|armv7Select the ARM target architecture (in the manual page but not in --help)man
-ffpu soft|vfpv2|vfpv3-d16|vfpv3Select the floating-point hardware (in the manual page but not in --help)man
-fthumbEnable Thumb/Thumb-2 code generation (in the manual page but not in --help)man
-fno-thumbDisable Thumb/Thumb-2 code generation (in the manual page but not in --help)man

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.