OS Manuals

/usr/bin/ocamlc

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

From ocaml 5.5.2-r0 (os), captured 2026-11-05 by running ocamlc --help (exit 0). permalink

Usage: ocamlc <options> <files>
Options are:

  -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
  -no-absname  Do not try to show absolute filenames in error messages (default)
  -annot  (deprecated) Save information in <filename>.annot
  -bin-annot  Save typedtree in <filename>.cmt
  -bin-annot-occurrences  Store every occurrence of a bound name in the .cmt file.
This information can be used by external tools to provide
features such as project-wide occurrences. This flag has
no effect in the absence of '-bin-annot'.
  -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
  -cmi-file <file>  Use the <file> interface file to type-check
  -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.
  -compat-32  Check that generated bytecode can run on 32-bit platforms
  -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)
  -custom  Link in custom mode
  -dllib <lib>  Use the dynamically-loaded library <lib>
  -dllib-suffixed <lib>  Use the dynamically-loaded library <lib>, with the runtime suffix appended to the name
  -dllpath <dir>  Add <dir> to the run-time search path for shared libraries
  -dtypes  (deprecated) same as -annot
  -for-pack <ident>  Generate code that can later be `packed' with
     ocamlc -pack -o <ident>.cmo
  -g  Save debugging information
  -no-g  Do not record debugging information (default)
  -stop-after {parsing|typing|lambda} Stop after the given compilation pass.
  -i  Print inferred interface
  -i-variance  Print inferred variances
  -I <dir>  Add <dir> to the list of include directories
  -H <dir>  Add <dir> to the list of "hidden" include directories
     (Like -I, but the program can not directly reference these dependencies)
  -impl <file>  Compile <file> as a .ml file
  -intf <file>  Compile <file> as a .mli file
  -intf-suffix <string>  Suffix for interface files (default: .mli)
  -intf_suffix <string>  (deprecated) same as -intf-suffix
  -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
  -keywords <version+list>  set keywords following the <version+list> spec:

                  -<version> if present specifies the base set of keywords

                    (if absent the current set of keywords is used)
                  -<list> is a "+"-separated list of keywords to add to

                    the base set of keywords.

  -labels  Use commuting label mode
  -linkall  Link all modules, even unused ones
  -make-runtime  Build a runtime system with given C objects and libraries
  -make_runtime  (deprecated) same as -make-runtime
  -modern  (deprecated) same as -labels
  -alias-deps  Do record dependencies for module aliases
  -no-alias-deps  Do not record dependencies for module aliases
  -app-funct  Activate applicative functors
  -no-app-funct  Deactivate applicative functors
  -no-check-prims  Do not check runtime for primitives
  -noassert  Do not compile assertion checks
  -noautolink  Do not automatically link C libraries specified in .cma files
  -nolabels  Ignore non-optional labels in types
  -nostdlib  Do not add default directory to the list of include directories
  -nocwd  Do not implicitly add the current directory to the load path
  -nopervasives  (undocumented)
  -o <file>  Set output file name to <file>
  -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
  -output-complete-exe  Output a self-contained executable, including runtime and C stubs
  -pack  Package the given .cmo files into one .cmo
  -pp <command>  Pipe sources through preprocessor <command>
  -ppx <command>  Pipe abstract syntax trees through preprocessor <command>
  -plugin <plugin>  (no longer supported)
  -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)
  -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.
  -safe-string  (default unconditionally since 5.0)
  -safer-matching  Do not use type information to optimize pattern-matching
  -set-runtime-default <param>=<value>  Set the default for runtime parameter <param> to <value> (see the manual for further details)
  -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 (default)
     (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
     (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
  -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)
  -use-runtime <file>  Generate bytecode for the given runtime system
  -use_runtime <file>  (deprecated) same as -use-runtime
  -launch-method <method>  Specify the mechanism for the bytecode launcher:
          exe - use the executable launcher in runtime-launch-info
          sh - use a #!, using sh if the interpreter path cannot be used
          /path/interpreter - use #!, or the given sh-compatible
            interpreter if the interpreter path cannot be used
  -runtime-search {disable|fallback|enable}  Control the way the bytecode header searches for the interpreter
    The following settings are supported:
      disable  use a fixed absolute path to the interpreter
      fallback search for interpreter only if not found at the absolute path
      enable   always search for the interpreter
    The default setting is 'disable'.
  -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
  -vmthread   (no longer supported)
  -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-74"
  -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"
  -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 13.2.)
  -use-prims <file>  (undocumented)
  -dno-unique-ids  (undocumented)
  -dunique-ids  (undocumented)
  -dno-canonical-ids  (undocumented)
  -dcanonical-ids  (undocumented)
  -dno-locations  (undocumented)
  -dlocations  (undocumented)
  -dsource  (undocumented)
  -dparsetree  (undocumented)
  -dparsetree-loc-ghost-invariants  (undocumented)
  -dtypedtree  (undocumented)
  -dshape  (undocumented)
  -dmatchcomp  (undocumented)
  -drawlambda  (undocumented)
  -dlambda  (undocumented)
  -dinstr  (undocumented)
  -dcamlprimc  (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
  -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 'ocamlc -depend -help' for details)
  -help  Display this list of options
  --help  Display this list of options
Options (127)
OptionDescriptionSource
-aBuild a library (.cma file) with the object files (.cmo 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
-no-absnameDo not try to show absolute filenames in error messages (default)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
-bin-annot-occurrencesStore every occurrence of a bound name in the .cmt file.help
-cCompile only (do not link)help + man
-cc commandUse ccomp as the C linker when linking in "custom runtime" mode (see the -custom option) and as the C compiler for compiling .c source files.help + man
-cclib optPass option <opt> to the C linkerhelp
-ccopt optPass the given option to the C compiler and linker, when linking in "custom runtime" mode (see the -custom option).help + man
-cmi-file fileType-check the source implementation to be compiled against the specified interface file (bypasses the normal lookup for .mli and .cmi files).help + man
-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 + man
-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 + man
-compat-32Check that the generated bytecode executable can run on 32-bit platforms and signal an error if it cannot.help + man
-configPrint the version number of ocamlc(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
-customLink in "custom runtime" mode.help + man
-dllib libUse the dynamically-loaded library <lib>help
-dllib-suffixed libUse the dynamically-loaded library <lib>, with the runtime suffix appended to the namehelp
-dllpath dirAdd the directory dir to the run-time search path for shared C libraries.help + man
-dtypes(deprecated) same as -annothelp
-for-pack identGenerate an object file (.cmo file) that can later be included as a sub-module (with the given access path) of a compilation unit constructed with -pack.help + man
-gAdd debugging information while compiling and linking.help + man
-no-gDo not record debugging information (default).help + man
-iCause the compiler to print all defined names (with their inferred types or their definitions) when compiling an implementation (.ml file).help + man
-i-varianceCause the compiler to print the computed variance of type parameters for every type declaration.help + man
-I dirAdd the given directory to the list of directories searched for compiled interface files (.cmi), compiled object code files (.cmo), libraries (.cma), and C libraries specified with -cclib -lxxx.help + man
-H dirAdd <dir> to the list of "hidden" include directories (Like -I, but the program can not directly reference these dependencies)help
-impl fileCompile the file filename as an implementation file, even if its extension is not .ml.help + man
-intf fileCompile the file filename as an interface file, even if its extension is not .mli.help + man
-intf-suffix stringRecognize file names ending with string as interface files (instead of the default .mli).help + man
-intf_suffix string(deprecated) same as -intf-suffixhelp
-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
-keywords version+listSet keywords according to the version+list specification.help + man
-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
-make-runtimeBuild a custom runtime system (in the file specified by option -o) incorporating the C object files and libraries given on the command line.help + man
-make_runtime(deprecated) same as -make-runtimehelp
-modern(deprecated) same as -labelshelp
-alias-depsDo record dependencies for module aliaseshelp
-no-alias-depsDo not record dependencies for module aliases.help + man
-app-functActivate applicative functorshelp
-no-app-functDeactivates the applicative behaviour of functors.help + man
-no-check-primsDo not check runtime for primitiveshelp
-noassertDo not compile assertion checks.help + man
-noautolinkWhen linking .cma libraries, ignore -custom, -cclib and -ccopt options potentially contained in the libraries (if these options were given when building the libraries).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 (.cmo), libraries (.cma), and C libraries…help + man
-nocwdDo not implicitly add the current directory to the load pathhelp
-nopervasives(undocumented)help
-o fileSpecify the name of the final output file, whether it is an executable, a compiled object (-c option), a library (-a option), a packed object (-pack option), or a C source or object file (-output-obj…help + man
-opaqueInterface file compiled with this option are marked so that other compilation units depending on it will not rely on any implementation details of the compiled implementation.help + man
-open moduleOpens the given module before processing the interface or implementation files.help + man
-output-objCause the linker to produce a C object file instead of a bytecode executable file.help + man
-output-complete-objSame as -output-obj except when creating an object file where it includes the runtime and autolink libraries.help + man
-output-complete-exeOutput a self-contained executable, including runtime and C stubshelp
-packBuild a bytecode object file (.cmo file) and its associated compiled interface (.cmi) that combines the object files given on the command line, making them appear as sub-modules of the output .cmo…help + man
-pp commandCause the compiler to call the given command as a preprocessor for each source file.help + man
-ppx commandAfter parsing, pipe the abstract syntax tree through the preprocessor command.help + man
-plugin plugin(no longer supported)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 + man
-rectypesAllow arbitrary recursive types during type-checking.help + man
-no-rectypesDo no allow arbitrary recursive types during type-checking.help + man
-runtime-variant strAdd suffix to the name of the runtime library that will be used by the program.help + man
-safe-stringEnforce the separation between types string and bytes, thereby making strings read-only.help + man
-safer-matchingDo not use type information to optimize pattern-matching.help + man
-set-runtime-default param>=<valueSet the default for runtime parameter <param> to <value> (see the manual for further details)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-sequenceForce the left-hand part of each sequence to have type unit.help + man
-no-strict-sequenceLeft-hand part of a sequence need not have type unit (default)help + man
-strict-formatsReject 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
-no-strict-formatsAccept 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
-thread(deprecated) same as -I +threadshelp
-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) and s.[i] constructs).help + man
-unsafe-stringIdentify the types string and bytes, thereby making strings writable.help + man
-use-runtime fileGenerate a bytecode executable file that can be executed on the custom runtime system runtime-name, built earlier with ocamlc -make-runtime runtime-name.help + man
-use_runtime file(deprecated) same as -use-runtimehelp
-launch-method methodSpecify the mechanism for the bytecode launcher: exe - use the executable launcher in runtime-launch-info sh - use a #!, using sh if the interpreter path cannot be used /path/interpreter - use #!, or…help + man
-runtime-search disable|fallback|enableControl the way the bytecode header searches for the interpreter The following settings are supported: disable use a fixed absolute path to the interpreter fallback search for interpreter only if not…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 C compiler and linker in -custom mode.help + man
-versionPrint version and exithelp
--versionPrint version and exithelp
-vmthread(no longer supported)help
-vnumPrint the version number of the compiler in short form (e.g. "3.11.0"), then exit.help + man
-w listEnable, disable, or mark as fatal the warnings specified by the argument warning-list.help + man
-warn-error listMark as errors the warnings specified in the argument warning-list.help + man
-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
-use-prims file(undocumented)help
-dno-unique-ids(undocumented)help
-dunique-ids(undocumented)help
-dno-canonical-ids(undocumented)help
-dcanonical-ids(undocumented)help
-dno-locations(undocumented)help
-dlocations(undocumented)help
-dsource(undocumented)help
-dparsetree(undocumented)help
-dparsetree-loc-ghost-invariants(undocumented)help
-dtypedtree(undocumented)help
-dshape(undocumented)help
-dmatchcomp(undocumented)help
-drawlambda(undocumented)help
-dlambda(undocumented)help
-dinstr(undocumented)help
-dcamlprimc(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
-helpDisplay a short usage summary and exit.help + man
--helpDisplay this list of optionshelp
-depend ocamldep-argsCompute dependencies, as ocamldep(1) would do. (in the manual page but not in --help)man
-stop-after passStop compilation after the given compilation pass. (in the manual page but not in --help)man
-nameDisable warning name. (in the manual page but not in --help)man
-numDisable warning number num. (in the manual page but not in --help)man
-num1..num2Disable all warnings between num1 and num2 (inclusive). (in the manual page but not in --help)man
-letterDisable the set of warnings corresponding to letter. (in the manual page but not in --help)man
-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

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