OCAMLC(1)
π OCAMLC(1) π
okay bestie, welcome to the ocamlc page from the General Commands Manual β¨ this is the OCaml bytecode compiler and she has a lot going on, but weβre gonna get through it together π«Ά
πΈ NAME πΈ
ocamlc β The OCaml bytecode compiler
π¦ SYNOPSIS π¦
ocamlc [options] filename...
ocamlc.opt [options] filename...
π DESCRIPTION π
The OCaml bytecode compiler ocamlc(1) compiles OCaml source files into bytecode object files and links those object files together to make standalone bytecode executable files. Those executable files are then run by the bytecode interpreter ocamlrun(1) π
The ocamlc(1) command has a command-line interface similar to the one used by most C compilers. It accepts several types of arguments and processes them sequentially, after all options have been processed:
- Arguments ending in
.mliare taken to be source files for compilation unit interfaces. Interfaces specify the names exported by compilation units: they declare value names with their types, define public data types, declare abstract data types, and so on. From the filex.mli, theocamlc(1)compiler produces a compiled interface in the filex.cmi. - Arguments ending in
.mlare taken to be source files for compilation unit implementations. Implementations provide definitions for the names exported by the unit, and also contain expressions to be evaluated for their side-effects. From the filex.ml, theocamlc(1)compiler produces compiled object bytecode in the filex.cmo.
If the interface file x.mli exists, the implementation x.ml is checked against the corresponding compiled interface x.cmi, which must exist. If no interface x.mli is provided, the compilation of x.ml produces a compiled interface file x.cmi in addition to the compiled object code file x.cmo. The file x.cmi produced corresponds to an interface that exports everything that is defined in the implementation x.ml.
- Arguments ending in
.cmoare taken to be compiled object bytecode. These files are linked together, along with the object files obtained by compiling.mlarguments (if any), and the OCaml standard library, to produce a standalone executable program. The order in which.cmoand.mlarguments are presented on the command line is relevant: compilation units are initialized in that order at run-time, and it is a link-time error to use a component of a unit before having initialized it. Hence, a givenx.cmofile must come before all.cmofiles that refer to the unitx. - Arguments ending in
.cmaare taken to be libraries of object bytecode. A library of object bytecode packs in a single file a set of object bytecode files (.cmofiles). Libraries are built withocamlc -a(see the description of the-aoption below). The object files contained in the library are linked as regular.cmofiles (see above), in the order specified when the.cmafile was built. The only difference is that if an object file contained in a library is not referenced anywhere in the program, then it is not linked in. - Arguments ending in
.care passed to the C compiler, which generates a.oobject file. This object file is linked with the program if the-customflag is set (see the description of-custombelow). - Arguments ending in
.oor.aare assumed to be C object files and libraries. They are passed to the C linker when linking in-custommode (see the description of-custombelow). - Arguments ending in
.soare assumed to be C shared libraries (DLLs). During linking, they are searched for external C functions referenced from the OCaml code, and their names are written in the generated bytecode executable. The run-time systemocamlrun(1)then loads them dynamically at program start-up time.
The output of the linking phase is a file containing compiled bytecode that can be executed by the OCaml bytecode interpreter: the command ocamlrun(1). If caml.out is the name of the file produced by the linking phase, the command ocamlrun caml.out arg1 arg2 ... argn executes the compiled code contained in caml.out, passing it as arguments the character strings arg1 to argn. (See ocamlrun(1) for more details.)
On most systems, the file produced by the linking phase can be run directly, as in: ./caml.out arg1 arg2 ... argn. The produced file has the executable bit set, and it manages to launch the bytecode interpreter by itself.
Two versions of the bytecode compiler exist: ocamlc.byte is a bytecode executable (i.e. compiled with ocamlc(1) itself), while ocamlc.opt is a native executable (i.e. compiled with ocamlopt(1)). ocamlc.opt may not be available in all installations of OCaml. ocamlc is an alias for the fastest of the two, i.e. for ocamlc.opt if it is available, otherwise for ocamlc.byte.
β¨ OPTIONS β¨
The following command-line options are recognized by ocamlc(1).
-aβ Build a library (.cmafile) with the object files (.cmofiles) given on the command line, instead of linking them into an executable file. The name of the library must be set with the-ooption.
If -custom, -cclib or -ccopt options are passed on the command line, these options are stored in the resulting .cma library. Then, linking with this library automatically adds back the -custom, -cclib and -ccopt options as if they had been provided on the command line, unless the -noautolink option is given. Additionally, a substring $CAMLORIGIN inside a -ccopt options will be replaced by the full path to the .cma library, excluding the filename.
-absnameβ Show absolute filenames in error messages.-no-absnameβ Do not try to show absolute filenames in error messages.-annotβ Deprecated since 4.11. Please use-bin-annotinstead.-bin-annotβ Dump detailed information about the compilation (types, bindings, tail-calls, etc) in binary format. The information for filesrc.mlis put into filesrc.cmt. In case of a type error, dump all the information inferred by the type-checker before the error. The annotation files produced by-bin-annotcontain more information and are much more compact than the files produced by-annot.-cβ Compile only. Suppress the linking phase of the compilation. Source code files are turned into compiled files, but no executable file is produced. This option is useful to compile modules separately.-ccccomp β Useccompas the C linker when linking in "custom runtime" mode (see the-customoption) and as the C compiler for compiling.csource files.-cclib-llibnameβ Pass the-llibnameoption to the C linker when linking in "custom runtime" mode (see the-customoption). This causes the given C library to be linked with the program.-ccoptoption β Pass the given option to the C compiler and linker, when linking in "custom runtime" mode (see the-customoption). For instance,-ccopt -Ldircauses the C linker to search for C libraries in directorydir.-colormode β Enable or disable colors in compiler messages (especially warnings and errors). The following modes are supported:autoβ use heuristics to enable colors only if the output supports them (an ANSI-compatible tty terminal);alwaysβ enable colors unconditionally;neverβ disable color output.
The environment variable OCAML_COLOR is considered if -color is not provided. Its values are auto/always/never as above.
If -color is not provided, OCAML_COLOR is not set and the environment variable NO_COLOR is set, then color output is disabled. Otherwise, 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.
-error-stylemode β Control the way error messages and warnings are printed. The following modes are supported:shortβ only print the error and its location;contextualβ likeshort, but also display the source code snippet corresponding to the location of the error.
The default setting is contextual.
The environment variable OCAML_ERROR_STYLE is considered if -error-style is not provided. Its values are short/contextual as above.
-compat-32β Check that the generated bytecode executable can run on 32-bit platforms and signal an error if it cannot. This is useful when compiling bytecode on a 64-bit machine.-configβ Print the version number ofocamlc(1)and a detailed summary of its configuration, then exit.-config-varβ Print the value of a specific configuration variable from the-configoutput, then exit. If the variable does not exist, the exit code is non-zero.-customβ Link in "custom runtime" mode. In the default linking mode, the linker produces bytecode that is intended to be executed with the shared runtime system,ocamlrun(1). In the custom runtime mode, the linker produces an output file that contains both the runtime system and the bytecode for the program. The resulting file is larger, but it can be executed directly, even if theocamlrun(1)command is not installed. Moreover, the "custom runtime" mode enables linking OCaml code with user-defined C functions.
Never use the strip(1) command on executables produced by ocamlc -custom, this would remove the bytecode part of the executable.
Security warning: never set the "setuid" or "setgid" bits on executables produced by ocamlc -custom, this would make them vulnerable to attacks.
-dependocamldep-args β Compute dependencies, asocamldep(1)would do.-dllib-llibnameβ Arrange for the C shared librarydlllibname.soto be loaded dynamically by the run-time systemocamlrun(1)at program start-up time.-dllib-suffixed-llibnameβ As for-dllibbut the name recorded is mangled byocamlrun(1)at program start-up time. This is used for C stub libraries; this option is used in particular byocamlmklib -suffixed.-dllpathdir β Add the directorydirto the run-time search path for shared C libraries. At link-time, shared libraries are searched in the standard search path (the one corresponding to the-Ioption). The-dllpathoption simply storesdirin the produced executable file, whereocamlrun(1)can find it and use it.-for-pack module-pathβ makes a.cmofile that later gets folded in as a sub-module (with the access path you gave) of a compilation unit built with-pack. Like,ocamlc -for-pack P -c A.mlgives youa.cmothat you can then feed toocamlc -pack -o P.cmo a.cmo. Heads up though: you can still pack a module compiled without-for-pack, it's just that exceptions will be printed with the wrong names π¬ so, yeah, do the thing.-gβ adds debugging information while compiling and linking. You literally need this if you wanna debug with ocamldebug(1), or get stack backtraces when the program dies on an uncaught exception. Non-negotiable tbh.-no-gβ don't record debugging info. This is the default.-iβ makes the compiler print all defined names (with their inferred types or their definitions) while compiling an implementation file (.ml). No compiled files (.cmoand.cmi) come out of this β it's purely a vibe-check of your types β¨ Also, since the output follows interface syntax, it's kind of a cheat code for writing an explicit interface (.mli) file: just redirect stdout to a.mlifile and then edit it to delete all the declarations of unexported names. Chef's kiss.-i-varianceβ prints the computed variance of type parameters for every type declaration. Without this flag, variance only shows up for private types or types without a manifest (e.g. abstract types).-cmi-file filenameβ type-checks the source implementation you're compiling against the interface file you specify, bypassing the normal lookup for.mliand.cmifiles.-I directoryβ adds the directory to the search list for compiled interface files (.cmi), compiled object code files (.cmo), libraries (.cma), and C libraries given via-cclib -lxxx. Default order: current directory first, then the standard library directory. Anything you add with-Igets searched after the current directory, in the order it appeared on the command line, but before the standard library directory. Peep option-nostdlibtoo.
If your directory starts with +, it's taken relative to the standard library directory. So -I +compiler-libs adds the compiler-libs subdirectory of the standard library to the search path. Cute, right?
-impl filenameβ compilesfilenameas an implementation file, even if its extension isn't.ml. Extensions are just suggestions π-intf filenameβ compilesfilenameas an interface file, even if its extension isn't.mli.-intf-suffix stringβ treats files ending instringas interface files (instead of the default.mli).-keep-docsβ keeps documentation strings in the generated.cmifiles.-keep-locsβ keeps locations in the generated.cmifiles.-keywords version+listβ sets keywords per theversion+listspec.
The spec starts with an optional version number that defines the base set of keywords, followed by a +-separated list of extra keywords to add to that base set. No explicit version number? Then the base set is the keywords of the current version of OCaml. And ngl, extra keywords that don't match any known keyword in the current version of the language will trigger an error whenever they show up in the source code π
-labelsβ labels are not ignored in types, labels can be used in applications, and labelled parameters can be given in any order. This is the default. It reverts option-nolabels.-launch-method methodβ says which mechanism normal bytecode executables use to find the interpreter. Supported methods:exeβ a small executable stub launcher contained in theruntime-launch-infofile is prepended to the bytecode image.shβ a#!header is used. If the full path to the required interpreter isn't suitable for a#!line, a small shell script is generated instead, using theshinterpreter found inPATH./path/interpreterβ same assh, except if the interpreter can't be used in a#!line then/path/interpreteris used instead of searching forshinPATH.
-linkallβ forces every module in libraries to be linked in. Without this flag, unreferenced modules stay out. When you're building a library (option-a), setting-linkallforces all subsequent links of programs involving that library to link all the modules inside it. When you're compiling a module (option-c), setting-linkallensures that module will always be linked if it's put in a library and that library gets linked. Nobody gets left out π«Ά-make-runtimeβ builds a custom runtime system (in the file given by option-o) that incorporates the C object files and libraries on the command line. Later you can use that custom runtime system to run bytecode executables produced with the optionocamlc -use-runtime runtime-name.-match-context-rows numberβ sets how many rows of context get used during pattern matching compilation. Lower values = faster compilation but less optimized code. Default is32.-no-alias-depsβ doesn't record dependencies for module aliases.-no-app-functβ deactivates the applicative behaviour of functors. With this on, every functor application generates new types in its result, so applying the same functor twice to the same argument gives you two incompatible structures. Yeah. Chaos, but intentional.-noassertβ doesn't compile assertion checks. Note that the special formassert falseis always compiled, because it's typed specially. This flag does nothing when linking already-compiled files.-noautolinkβ when linking.cmalibraries, ignores-custom,-ccliband-ccoptoptions potentially contained in the libraries (if those options were given when the libraries were built). Super useful when a library carries around wrong specs for C libraries or C options β in that case, during linking, set-noautolinkand just pass the correct C libraries and options on the command line yourself π₯-nolabelsβ ignores non-optional labels in types. Labels can't be used in applications, and parameter order becomes strict. See also option-labels.-nostdlibβ doesn't 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 specified with-cclib -lxxx. See also option-I.-o filenameβ names the final output file, whatever it happens to be: an executable, a compiled object (-c), a library (-a), a packed object (-pack), or a C source or object file (-output-objand-output-complete-obj).
The default executable output name is platform-dependent: a.out on Unix, camlprog.exe on Windows.
You can also use this when compiling but not linking an interface or implementation file (-c), in which case it sets both the name of the cmi or cmo file and the name of the compilation unit to the filename up to the first dot.
-opaqueβ interface files compiled with this are marked so that other compilation units depending on it won't rely on any implementation details of the compiled implementation. The native compiler won't touch the.cmxfile of this unit β and won't even warn if it's missing. Speeds up compilation for both initial and incremental builds, at the cost of the generated code's performance. Trade-offs, bestie π-open moduleβ opens the given module before processing the interface or implementation files. Give several-openoptions and they're processed in order, exactly as ifopen! module1;;β¦open! moduleN;;were added to the top of each file.-output-objβ makes the linker produce a C object file instead of a bytecode executable. Perfect for wrapping OCaml code as a C library callable from any C program π The output object file's name has to be set with-o. You can also use this to produce a C source file (.cextension) or a compiled shared/dynamic library (.soextension).-output-complete-objβ same as-output-obj, except when creating an object file it also includes the runtime and autolink libraries.-packβ builds a bytecode object file (.cmo) and its associated compiled interface (.cmi) that combines the object files on the command line, making them show up as sub-modules of the output.cmofile. Name the output.cmowith the-ooption. For example:
ocamlc -pack -o p.cmo a.cmo b.cmo c.cmo
generates the compiled files p.cmo and p.cmi describing a compilation unit with three sub-modules A, B and C, matching the contents of a.cmo, b.cmo and c.cmo. You can reference those contents as P.A, P.B and P.C for the rest of the program β¨
The .cmo object files being combined must have been compiled with the appropriate -for-pack option. In the example above, a.cmo, b.cmo and c.cmo must have been compiled with ocamlc -for-pack P. No shortcuts, sorry π
-pp commandβ makes the compiler call the given command as a preprocessor for each source file. The output ofcommandis redirected to an intermediate file, which then gets compiled. If there are no compilation errors, that intermediate file is deleted afterwards.-ppx commandβ after parsing, pipes the abstract syntax tree through the preprocessorcommand. The moduleAst_mapper(3)implements the external interface of a preprocessor π¦-principalβ bestie, this one checks the information path during type-checking to make sure all types are derived in a principal way. When you're using labelled arguments and/or polymorphic methods, this flag is required to ensure future versions of the compiler will be able to infer types correctly, even if internal algorithms change. All programs accepted in-principalmode are also accepted in the default mode with equivalent types, but different binary signatures, and this may slow down type checking; yet it is a good idea to use it once before publishing source code. π-no-principalβ do not check principality of type inference. This is the default.-rectypesβ allow arbitrary recursive types during type-checking. By default, only recursive types where the recursion goes through an object type are supported. Note that once you have created an interface using this flag, you must use it again for all dependencies. π-no-rectypesβ do not allow arbitrary recursive types during type-checking. This is the default.-runtime-search methodβ control whether the header used by normal bytecode executables is permitted to search for the interpreter, or requires it to be at a fixed location. The following methods are supported:disableβ a fixed absolute path to the interpreter is used, and the executable will not launch if the interpreter is not found at this location.fallbackβ a fixed absolute path to the interpreter is used, but if the executable cannot find the interpreter at this location then it will search first in the directory containing the executable and then inPATH.enableβ the executable searches for the interpreter first in the directory containing the executable and then inPATH. No absolute path to the interpreter is recorded.
-runtime-variant suffixβ addsuffixto the name of the runtime library that will be used by the program. If OCaml was configured with them, the debug (dsuffix) and instrument (isuffix) runtimes can be used. π-safe-stringβ enforce the separation between typesstringandbytes, thereby making strings read-only. This is the default.-safer-matchingβ do not use type information to optimize pattern-matching. This allows to detect match failures even if a pattern-matching was wrongly assumed to be exhaustive. This only impacts GADT and polymorphic variant compilation. π-set-runtime-default setting=valueβ when linking an executable, override the default value for a runtime setting. The only currently supported setting is:standard_library_defaultβ specifies the default location used by the executable to locate the Standard Library. By default, this is the absolute path to the Standard Library the compiler itself was configured with.
-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. β¨-stop-after passβ stop compilation after the given compilation pass. The currently supported passes are:parsing,typing.-strict-sequenceβ force the left-hand part of each sequence to have typeunit.-no-strict-sequenceβ left-hand part of a sequence need not have typeunit. This is the default.-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]. π¦-no-unboxed-typesβ when a type is unboxable it will be boxed unless annotated with[@@ocaml.unboxed]. This is the default.-unsafeβ turn bound checking off for array and string accesses (thev.(i)ands.[i]constructs). Programs compiled with-unsafeare therefore slightly faster, but unsafe: anything can happen if the program accesses an array or string outside of its bounds. π
bestie, seriously: -unsafe is giving βyoloβ and not in a cute way. Out-of-bounds access = anything can happen. Youβve been warned. π
-unsafe-stringβ identify the typesstringandbytes, thereby making strings writable. This is intended for compatibility with old source code and should not be used with new software. π©-use-runtime runtime-nameβ generate a bytecode executable file that can be executed on the custom runtime systemruntime-name, built earlier withocamlc -make-runtime runtime-name.-vβ print the version number of the compiler and the location of the standard library directory, then exit.-verboseβ print all external commands before they are executed, in particular invocations of the C compiler and linker in-custommode. Useful to debug C library problems. π οΈ-vnumor-versionβ print the version number of the compiler in short form (e.g."3.11.0"), then exit.-w warning-listβ enable, disable, or mark as fatal the warnings specified by the argumentwarning-list.
Each warning can be enabled or disabled, and each warning can be fatal or non-fatal. If a warning is disabled, it isn't displayed and doesn't affect compilation in any way (even if it is fatal). If a warning is enabled, it is displayed normally by the compiler whenever the source code triggers it. If it is enabled and fatal, the compiler will also stop with an error after displaying it. π¨
The warning-list argument is either a mnemonic warning specifier or a sequence of single character warning specifiers, with no separators between them. A mnemonic warning specifier is one of the following:
+nameβ enable warningname.-nameβ disable warningname.@nameβ enable and mark as fatal warningname.
A single character warning specifier is one of the following:
+numβ enable warning numbernum.-numβ disable warning numbernum.@numβ enable and mark as fatal warning numbernum.+num1..num2β enable all warnings betweennum1andnum2(inclusive).-num1..num2β disable all warnings betweennum1andnum2(inclusive).@num1..num2β enable and mark as fatal all warnings betweennum1andnum2(inclusive).+letterβ enable the set of warnings corresponding toletter. Thelettermay be uppercase or lowercase.-letterβ disable the set of warnings corresponding toletter. Thelettermay be uppercase or lowercase.@letterβ enable and mark as fatal the set of warnings corresponding toletter. Thelettermay be uppercase or lowercase.uppercase-letterβ enable the set of warnings corresponding touppercase-letter.lowercase-letterβ disable the set of warnings corresponding tolowercase-letter.
The warning numbers and mnemonic names are as follows:
1[comment-start]β suspicious-looking start-of-comment mark.2[comment-not-end]β suspicious-looking end-of-comment mark.3β deprecated feature.4[fragile-match]β fragile pattern matching: matching that will remain complete even if additional constructors are added to one of the variant types matched.5[ignored-partial-application]β partially applied function: expression whose result has function type and is ignored.6[labels-omitted]β label omitted in function application.7[method-override]β method overridden without using the"method!"keyword.8[partial-match]β partial match: missing cases in pattern-matching.9[missing-record-field-pattern]β missing fields in a record pattern.10[non-unit-statement]β expression on the left-hand side of a sequence that doesn't have typeunit(and that is not a function, see warning number 5).11[redundant-case]β redundant case in a pattern matching (unused match case).12[redundant-subpat]β redundant sub-pattern in a pattern-matching.13[instance-variable-override]β override of an instance variable.14[illegal-backslash]β illegal backslash escape in a string constant.15[implicit-public-methods]β private method made public implicitly.16[unerasable-optional-argument]β unerasable optional argument.17[undeclared-virtual-method]β undeclared virtual method.18[not-principal]β non-principal type.19[non-principal-labels]β type without principality.20[ignored-extra-argument]β unused function argument.21[nonreturning-statement]β non-returning statement.22[preprocessor]β preprocessor warning.23[useless-record-with]β useless recordwithclause.24[bad-module-name]β bad module name: the source file name is not a valid OCaml module name.25β deprecated: now part of warning 8.26[unused-var]β suspicious unused variable: unused variable that is bound withletoras, and doesn't start with an underscore (_) character.27[unused-var-strict]β innocuous unused variable: unused variable that is not bound withletnoras, and doesn't start with an underscore (_) character.28[wildcard-arg-to-constant-constr]β a pattern contains a constant constructor applied to the underscore (_) pattern.29[eol-in-string]β a non-escaped end-of-line was found in a string constant. This may cause portability problems between Unix and Windows. π
30[duplicate-definitions] β two labels or constructors with the exact same name are defined in two mutually recursive types π«31[module-linked-twice] β a module is linked twice into the same executable, bestie, pick one32[unused-value-declaration] β unused value declaration33[unused-open] β unusedopenstatement34[unused-type-declaration] β unused type declaration35[unused-for-index] β unused for-loop index36[unused-ancestor] β unused ancestor variable37[unused-constructor] β unused constructor38[unused-extension] β unused extension constructor39[unused-rec-flag] β unusedrecflag40[name-out-of-scope] β constructor or label name used out of scope41[ambiguous-name] β ambiguous constructor or label name42[disambiguated-name] β disambiguated constructor or label name43[nonoptional-label] β nonoptional label applied as optional44[open-shadow-identifier] β anopenstatement shadows an already defined identifier45[open-shadow-label-constructor] β anopenstatement shadows an already defined label or constructor46[bad-env-variable] β error in environment variable47[attribute-payload] β illegal attribute payload48[eliminated-optional-arguments] β implicit elimination of optional arguments49[no-cmi-file] β missingcmifile when looking up a module alias50[unexpected-docstring] β unexpected documentation comment51[wrong-tailcall-expectation] β function call annotated with an incorrect@tailcallattribute52[fragile-literal-pattern] β fragile constant pattern53[misplaced-attribute] β attribute cannot appear in this context54[duplicated-attribute] β attribute used more than once on an expression55[inlining-impossible] β inlining impossible, it's giving "can't sit with us"56[unreachable-case] β unreachable case in a pattern-matching (based on type information)57[ambiguous-var-in-pattern-guard] β ambiguous or-pattern variables under guard58[no-cmx-file] β missingcmxfile59[flambda-assignment-to-non-mutable-value] β assignment on non-mutable value60[unused-module] β unused module declaration61[unboxable-type-in-prim-decl] β unannotated unboxable type in primitive declaration62[constraint-on-gadt] β type constraint on GADT type declaration63[erroneous-printed-signature] β erroneous printed signature64[unsafe-array-syntax-without-parsing] β-unsafeused with a preprocessor returning a syntax tree65[redefining-unit] β type declaration defining a new'()'constructor66[unused-open-bang] β unusedopen!statement67[unused-functor-parameter] β unused functor parameter68[match-on-mutable-state-prevent-uncurry] β pattern-matching that depends on mutable state prevents the remaining arguments from being uncurried69[unused-field] β unused record field70[missing-mli] β missing interface file71[unused-tmc-attribute] β unused@tail_mod_consattribute72[tmc-breaks-tailcall] β a tail call is turned into a non-tail call by the@tail_mod_constransformation73[generative-application-expects-unit] β a generative functor is applied to an empty structure (struct end) rather than to()
Okay so here's the tea on the letters π΅ β they stand for the following sets of warnings. Any letter that isn't mentioned here? That's the empty set, babe, it means nothing:
Aβ all warningsCβ1,2Dβ3Eβ4Fβ5Kβ32,33,34,35,36,37,38,39Lβ6Mβ7Pβ8Rβ9Sβ10Uβ11,12Vβ13Xβ14,15,16,17,18,19,20,21,22,23,24,25,30Yβ26Zβ27
The default setting is:
-w +a-4-7-9-27-29-30-32..42-44-45-48-50-60-66..70-74
And lowkey important: warnings 5 and 10 are not always triggered β it depends on the internals of the type checker, so don't come for me if they ghost you π
-warn-errorwarning-list β marks the warnings listed in warning-list as errors. The compiler straight-up stops with an error the moment one of them is emitted π The warning-list means exactly the same thing as it does for-w:- a
+sign (or an uppercase letter) marks the corresponding warnings as fatal - a
-sign (or a lowercase letter) turns them back into non-fatal warnings - a
@sign both enables and marks as fatal the corresponding warnings
- a
Note: not recommended to use -warn-error in production code, bestie π because it will almost certainly prevent compiling your program with later versions of OCaml when they add new warnings or modify existing warnings.
The default setting is -warn-error -a (no warning is fatal).
-warn-helpβ shows the description of all available warning numbers. Very much the "let me look it up for you" icon β¨-whereβ prints the location of the standard library, then exits.-with-runtimeβ includes the runtime system in the generated program. This is the default, so it's already doing that for you π-without-runtimeβ the compiler does not include the runtime system (nor a reference to it) in the generated program; you have to supply it separately. Your problem now, babes.-file β processes file as a file name, even if it starts with a dash (-) character. Yes, even then. Main character behaviour.-helpor--helpβ displays a short usage summary and exits. The classic.
π SEE ALSO π
And the OCaml user's manual, chapter "Batch compilation" π β go read it, iykyk.
And that's the whole page, bestie π you made it to the end!! This iconic little number is the OCAMLC(1) manual page, straight out of the OCaml docs β the compiler's very own. Periodt. πβ¨
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- nixpkgs unstable: ocaml 5.5.1
- nixpkgs unstable: ocaml-solo5 1.3.5
- Copyright 1996 Institut National de Recherche en Informatique et
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms