summaryrefslogtreecommitdiff
path: root/manual/src/cmds/unified-options.etex
blob: 7351c8dd0c3e43d96aa699c9943b2f42663f5c46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
%
% This file describes the native/bytecode compiler and toplevel
% options. Since specific options can exist in only a subset of
% \{toplevel, bytecode compiler, native compiler \} and their description
% might differ across this subset, this file uses macros to adapt the
% description tool by tool:
\long\def\comp#1{\ifcomp#1\else\fi}
% \long is needed for multiparagraph macros
\long\def\nat#1{\ifnat#1\else\fi}
\long\def\top#1{\iftop#1\else\fi}
\long\def\notop#1{\iftop\else#1\fi}
% ( Note that the previous definitions relies on the three boolean values
%   \top, \nat and \comp. The manual section must therefore
%   set these boolean values accordingly.
% )
% The macros (\comp, \nat, \top) adds a supplementary text
% if we are respectively in the (bytecode compiler, native compiler, toplevel)
% section.
% The toplevel options are quite different from the compilers' options.
% It is therefore useful to have also a substractive \notop macro
% that prints its content only outside of the topvel section
%
% For instance, to add an option "-foo" that applies to the native and
% bytecode compiler, one can write
% \notop{\item["-foo"]
%   ...
% }
%
% Similarly, an option "-bar" only available in the native compiler
% can be introduced with
% \nat{\item["-bar"]
%   ...
% }
% These macros can be also used to add information that are only relevant to
% some tools or differ slightly from one tool to another. For instance, we
% define the following macro for the pairs cma/cmxa cmo/cmxo and ocamlc/ocamlopt
%
\def\cma{\comp{.cma}\nat{.cmxa}}
\def\cmo{\comp{.cmo}\nat{.cmx}}
\def\qcmo{{\machine\cmo}}
\def\qcma{{\machine\cma}}
\def\ocamlx{\comp{ocamlc}\nat{ocamlopt}}
%
%
\begin{options}
\notop{%
\item["-a"]
Build a library(\nat{".cmxa" and ".a"/".lib" files}\comp{".cma" file})
with the object files (\nat{".cmx" and ".o"/".obj" files}\comp{ ".cmo" files})
given on the command line, instead of linking them into an executable file.
The name of the library must be set with the "-o" option.

If \comp{"-custom", }"-cclib" or "-ccopt" options are passed on the command
line, these options are stored in the resulting \qcma library. Then,
linking with this library automatically adds back the \comp{"-custom", }
"-cclib" and "-ccopt" options as if they had been provided on the
command line, unless the "-noautolink" option is given.
}%notop

\item["-absname"]
Force error messages to show absolute paths for file names.

\item["-no-absname"]
Do not try to show absolute filenames in error messages.

\notop{\item["-annot"]
Deprecated since OCaml 4.11. Please use "-bin-annot" instead.
}%notop

\item["-args" \var{filename}]
Read additional newline-terminated command line arguments from \var{filename}.
\top{It is not possible to pass a \var{scriptfile} via file to the toplevel.
}%top
\item["-args0" \var{filename}]
 Read additional null character terminated command line arguments from
 \var{filename}.
\top{It is not possible to pass a \var{scriptfile} via file to the toplevel.
}%top


\notop{\item["-bin-annot"]
Dump detailed information about the compilation (types, bindings,
tail-calls, etc) in binary format. The information for file \var{src}".ml"
(resp. \var{src}".mli") is put into file \var{src}".cmt"
(resp. \var{src}".cmti").  In case of a type error, dump
all the information inferred by the type-checker before the error.
The "*.cmt" and "*.cmti" files produced by "-bin-annot" contain
more information and are much more compact than the files produced by
"-annot".
}%notop

\notop{\item["-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.
}%notop

\notop{%
\item["-cc" \var{ccomp}]
Use \var{ccomp} as the C linker \nat{called to build the final executable }
\comp{when linking in ``custom runtime'' mode (see the "-custom" option)}
and as the C compiler for compiling ".c" source files.
}%notop

\notop{%
\item["-cclib" "-l"\var{libname}]
Pass the "-l"\var{libname} option to the \comp{C} linker
\comp{when linking in ``custom runtime'' mode (see the "-custom" option)}.
This causes the given C library to be linked with the program.
}%notop

\notop{%
\item["-ccopt" \var{option}]
Pass the given option to the C compiler and linker.
\comp{When linking in ``custom runtime'' mode, for instance }%
\nat{For instance, }%
"-ccopt -L"\var{dir} causes the C linker to search for C libraries in
directory \var{dir}. \comp{(See the "-custom" option.)}
}%notop

\notop{%
\item["-cmi-file" \var{filename}]
Use the given interface file to type-check the ML source file to compile.
When this option is not specified, the compiler looks for a \var{.mli} file
with the same base name than the implementation it is compiling and in the
same directory. If such a file is found, the compiler looks for a
corresponding \var{.cmi} file in the included directories and reports an
error if it fails to find one.
}%notop

\notop{%
\item["-color" \var{mode}]
Enable or disable colors in compiler messages (especially warnings and errors).
The following modes are supported:
\begin{description}
  \item["auto"] use heuristics to enable colors only if the output supports them
   (an ANSI-compatible tty terminal);
  \item["always"] enable colors unconditionally;
  \item["never"] disable color output.
\end{description}

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.
}%notop

\notop{%
\item["-error-style" \var{mode}]
Control the way error messages and warnings are printed.
The following modes are supported:
\begin{description}
  \item["short"] only print the error and its location;
  \item["contextual"] like "short", but also display the source code snippet
   corresponding to the location of the error.
  \end{description}
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.
}%notop

\comp{%
\item["-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.
}%comp

\nat{%
\item["-compact"]
Optimize the produced code for space rather than for time. This
results in slightly smaller but slightly slower programs. The default is to
optimize for speed.
}%nat

\notop{%
\item["-config"]
Print the version number of {\machine\ocamlx} and a detailed
summary of its configuration, then exit.
}%notop

\notop{%
\item["-config-var" \var{var}]
Print the value of a specific configuration variable from the
"-config" output, then exit. If the variable does not exist, the exit
code is non-zero. This option is only available since OCaml 4.08,
so script authors should have a fallback for older versions.
}%notop

\comp{%
\item["-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". 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 the "ocamlrun" command is not
installed. Moreover, the ``custom runtime'' mode enables static
linking of OCaml code with user-defined C functions, as described in
chapter~\ref{c:intf-c}.
\begin{unix}
Never use the "strip" command on executables produced by "ocamlc -custom",
this would remove the bytecode part of the executable.
\end{unix}
\begin{unix}
Security warning: never set the ``setuid'' or ``setgid'' bits on executables
produced by "ocamlc -custom", this would make them vulnerable to attacks.
\end{unix}
}%comp

\notop{%
\item["-depend" \var{ocamldep-args}]
Compute dependencies, as the "ocamldep" command would do. The remaining
arguments are interpreted as if they were given to the "ocamldep" command.
}%notop

\comp{
\item["-dllib" "-l"\var{libname}]
Arrange for the C shared library "dll"\var{libname}".so"
("dll"\var{libname}".dll" under Windows) to be loaded dynamically
by the run-time system "ocamlrun" at program start-up time.
}%comp

\comp{\item["-dllpath" \var{dir}]
Adds the directory \var{dir} to 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 "-I" option).
The "-dllpath" option simply stores \var{dir} in the produced
executable file, where "ocamlrun" can find it and use it as
described in section~\ref{s:ocamlrun-dllpath}.
}%comp

\notop{%
\item["-for-pack" \var{module-path}]
Generate an object file (\qcmo\nat{ and ".o"/".obj" files})
that can later be included
as a sub-module (with the given access path) of a compilation unit
constructed with "-pack".  For instance,
{\machine\ocamlx\ -for-pack\ P\ -c\ A.ml}
will generate {\machine a.\cmo}\nat{ and "a.o" files} that can
later be used with {\machine \ocamlx\ -pack\ -o\ P\cmo\ a\cmo}.
Note: you can still pack a module that was compiled without
"-for-pack" but in this case exceptions will be printed with the wrong
names.
}%notop

\notop{%
\item["-g"]
Add debugging information while compiling and linking. This option is
required in order to \comp{be able to debug the program with "ocamldebug"
(see chapter~\ref{c:debugger}), and to} produce stack backtraces when
the program terminates on an uncaught exception (see
section~\ref{s:ocamlrun-options}).
}%notop

\notop{%
\item["-i"]
Cause the compiler to print all defined names (with their inferred
types or their definitions) when compiling an implementation (".ml"
file).  No compiled files (".cmo" and ".cmi" files) are produced.
This can be useful to check the types inferred by the
compiler. Also, since the output follows the syntax of interfaces, it
can help in writing an explicit interface (".mli" file) for a file:
just redirect the standard output of the compiler to a ".mli" file,
and edit that file to remove all declarations of unexported names.
}%notop

\item["-I" \var{directory}]
Add the given directory to the list of directories searched for
\nat{compiled interface files (".cmi"), compiled object code files (".cmx"),
and libraries (".cmxa").}
\comp{compiled interface files (".cmi"), compiled object code files ".cmo",
libraries (".cma") and C libraries specified with "-cclib -lxxx".}
\top{source and compiled files.}
By default, the current directory is searched first, then the standard
library directory. Directories added with "-I" are searched after the
current directory, in the order in which they were given on the command line,
but before the standard library directory. See also option "-nostdlib".

If the given directory starts with "+", it is taken relative to the
standard library directory.  For instance, "-I +unix" adds the
subdirectory "unix" of the standard library to the search path.

\top{%
Directories can also be added to the list once
the toplevel is running with the "#directory" directive
(section~\ref{s:toplevel-directives}).
}%top

\top{%
\item["-init" \var{file}]
Load the given file instead of the default initialization file.
The default file is ".ocamlinit" in the current directory if it
exists, otherwise "XDG_CONFIG_HOME/ocaml/init.ml" or
".ocamlinit" in the user's home directory.
}%top

\notop{%
\item["-impl" \var{filename}]
Compile the file \var{filename} as an implementation file, even if its
extension is not ".ml".
}%notop

\nat{%
\item["-inline" \var{n}]
Set aggressiveness of inlining to \var{n}, where \var{n} is a positive
integer. Specifying "-inline 0" prevents all functions from being
inlined, except those whose body is smaller than the call site. Thus,
inlining causes no expansion in code size. The default aggressiveness,
"-inline 1", allows slightly larger functions to be inlined, resulting
in a slight expansion in code size. Higher values for the "-inline"
option cause larger and larger functions to become candidate for
inlining, but can result in a serious increase in code size.
}%nat

\notop{%
\item["-intf" \var{filename}]
Compile the file \var{filename} as an interface file, even if its
extension is not ".mli".
}%notop

\notop{%
\item["-intf-suffix" \var{string}]
Recognize file names ending with \var{string} as interface files
(instead of the default ".mli").
}%\notop

\item["-labels"]
Labels are not ignored in types, labels may be used in applications,
and labelled parameters can be given in any order.  This is the default.

\notop{%
\item["-linkall"]
Force all modules contained in libraries to be linked in. If this
flag is not given, unreferenced modules are not linked in. When
building a library (option "-a"), setting the "-linkall" option forces all
subsequent links of programs involving that library to link all the
modules contained in the library.  When compiling a module (option
"-c"), setting the "-linkall" option ensures that this module will
always be linked if it is put in a library and this library is linked.
}%notop

\nat{%
\item["-linscan"]
Use linear scan register allocation.  Compiling with this allocator is faster
than with the usual graph coloring allocator, sometimes quite drastically so for
long functions and modules. On the other hand, the generated code can be a bit
slower.
}%nat

\comp{%
\item["-make-runtime"]
Build a custom runtime system (in the file specified by option "-o")
incorporating the C object files and libraries given on the command
line.  This custom runtime system can be used later to execute
bytecode executables produced with the
"ocamlc -use-runtime" \var{runtime-name} option.
See section~\ref{ss:custom-runtime} for more information.
}%comp

\notop{%
\item["-match-context-rows"]
Set the number of rows of context used for optimization during
pattern matching compilation. The default value is 32. Lower values
cause faster compilation, but less optimized code. This advanced
option is meant for use in the event that a pattern-match-heavy
program leads to significant increases in compilation time.
}%notop

\notop{%
\item["-no-alias-deps"]
Do not record dependencies for module aliases. See
section~\ref{s:module-alias} for more information.
}%notop

\item["-no-app-funct"]
Deactivates the applicative behaviour of functors. With this option,
each functor application generates new types in its result and
applying the same functor twice to the same argument yields two
incompatible structures.

\nat{%
\item["-no-float-const-prop"]
Deactivates the constant propagation for floating-point operations.
This option should be given if the program changes the float rounding
mode during its execution.
}%nat

\item["-noassert"]
Do not compile assertion checks.  Note that the special form
"assert false" is always compiled because it is typed specially.
\notop{This flag has no effect when linking already-compiled files.}

\notop{%
\item["-noautolink"]
When linking \qcma libraries, ignore \comp{"-custom",} "-cclib" and "-ccopt"
options potentially contained in the libraries (if these options were
given when building the libraries).  This can be useful if a library
contains incorrect specifications of C libraries or C options; in this
case, during linking, set "-noautolink" and pass the correct C
libraries and options on the command line.
}%

\nat{%
\item["-nodynlink"]
Allow the compiler to use some optimizations that are valid only for
code that is statically linked to produce a non-relocatable
executable.  The generated code cannot be linked to produce a shared
library nor a position-independent executable (PIE).  Many operating
systems produce PIEs by default, causing errors when linking code
compiled with "-nodynlink".  Either do not use "-nodynlink" or pass
the option "-ccopt -no-pie" at link-time.
}%nat

\item["-nolabels"]
Ignore non-optional labels in types. Labels cannot be used in
applications, and parameter order becomes strict.

\top{%
\item["-noprompt"]
Do not display any prompt when waiting for input.
}%top

\top{%
\item["-nopromptcont"]
Do not display the secondary prompt when waiting for continuation
lines in multi-line inputs.  This should be used e.g. when running
"ocaml" in an "emacs" window.
}%top

\item["-nostdlib"]
\top{%
Do not include the standard library directory in the list of
directories searched for source and compiled files.
}%top
\comp{%
Do not include the standard library directory in 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".
}%comp
\nat{%
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"). See also option
"-I".
}%nat

\notop{%
\item["-o" \var{output-file}]
Specify the name of the output file to produce. For executable files, the
default output name is "a.out" under Unix and "camlprog.exe" under
Windows. If the "-a" option is given, specify the name of the library
produced.  If the "-pack" option is given, specify the name of the
packed object file produced.  If the "-output-obj" or "-output-complete-obj"
options are given, specify the name of the produced object file.
\nat{If the "-shared" option is given, specify the name of plugin
file produced.}
\comp{If the "-c" option is given, specify the name of the object
file produced for the {\em next} source file that appears on the
command line.}
}%notop

\notop{%
\item["-opaque"]
When the native compiler compiles an implementation, by default it
produces a ".cmx" file containing information for cross-module
optimization. It also expects ".cmx" files to be present for the
dependencies of the currently compiled source, and uses them for
optimization. Since OCaml 4.03, the compiler will emit a warning if it
is unable to locate the ".cmx" file of one of those dependencies.

The "-opaque" option, available since 4.04, disables cross-module
optimization information for the currently compiled unit. When
compiling ".mli" interface, using "-opaque" marks the compiled ".cmi"
interface so that subsequent compilations of modules that depend on it
will not rely on the corresponding ".cmx" file, nor warn if it is
absent. When the native compiler compiles a ".ml" implementation,
using "-opaque" generates a ".cmx" that does not contain any
cross-module optimization information.

Using this option may degrade the quality of generated code, but it
reduces compilation time, both on clean and incremental
builds. Indeed, with the native compiler, when the implementation of
a compilation unit changes, all the units that depend on it may need
to be recompiled -- because the cross-module information may have
changed. If the compilation unit whose implementation changed was
compiled with "-opaque", no such recompilation needs to occur. This
option can thus be used, for example, to get faster edit-compile-test
feedback loops.
}%notop

\notop{%
\item["-open" \var{Module}]
Opens the given module before processing the interface or
implementation files. If several "-open" options are given,
they are processed in order, just as if
the statements "open!" \var{Module1}";;" "..." "open!" \var{ModuleN}";;"
were added at the top of each file.
}%notop

\notop{%
\item["-output-obj"]
Cause the linker to produce a C object file instead of
\comp{a bytecode executable file}\nat{an executable file}.
This is useful to wrap OCaml code as a C library,
callable from any C program. See chapter~\ref{c:intf-c},
section~\ref{ss:c-embedded-code}. The name of the output object file
must be set with the "-o" option.
This option can also be used to produce a \comp{C source file (".c" extension)
or a} compiled shared/dynamic library (".so" extension, ".dll" under Windows).
}%notop

\comp{%
\item["-output-complete-exe"]
Build a self-contained executable by linking a C object file containing the
bytecode program, the OCaml runtime system and any other static C code given to
"ocamlc". The resulting effect is similar to "-custom", except that the bytecode
is embedded in the C code so it is no longer accessible to tools such as
"ocamldebug". On the other hand, the resulting binary is resistant to "strip".
}%comp

\notop{%
\item["-output-complete-obj"]
Same as "-output-obj" options except the object file produced includes the
runtime and autolink libraries.
}%notop

\nat{%
\item["-pack"]
Build an object file (".cmx" and ".o"/".obj" 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 ".cmx" file.  The name of the output ".cmx" file must be
given with the "-o" option.  For instance,
\begin{verbatim}
        ocamlopt -pack -o P.cmx A.cmx B.cmx C.cmx
\end{verbatim}
generates compiled files "P.cmx", "P.o" and "P.cmi" describing a
compilation unit having three sub-modules "A", "B" and "C",
corresponding to the contents of the object files "A.cmx", "B.cmx" and
"C.cmx".  These contents can be referenced as "P.A", "P.B" and "P.C"
in the remainder of the program.

The ".cmx" object files being combined must have been compiled with
the appropriate "-for-pack" option.  In the example above,
"A.cmx", "B.cmx" and "C.cmx" must have been compiled with
"ocamlopt -for-pack P".

Multiple levels of packing can be achieved by combining "-pack" with
"-for-pack".  Consider the following example:
\begin{verbatim}
        ocamlopt -for-pack P.Q -c A.ml
        ocamlopt -pack -o Q.cmx -for-pack P A.cmx
        ocamlopt -for-pack P -c B.ml
        ocamlopt -pack -o P.cmx Q.cmx B.cmx
\end{verbatim}
The resulting "P.cmx" object file has sub-modules "P.Q", "P.Q.A"
and "P.B".
}%nat

\comp{%
\item["-pack"]
Build 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" file.  The name of the output ".cmo" file must be
given with the "-o" option.  For instance,
\begin{verbatim}
        ocamlc -pack -o p.cmo a.cmo b.cmo c.cmo
\end{verbatim}
generates compiled files "p.cmo" and "p.cmi" describing a compilation
unit having three sub-modules "A", "B" and "C", corresponding to the
contents of the object files "a.cmo", "b.cmo" and "c.cmo".  These
contents can be referenced as "P.A", "P.B" and "P.C" in the remainder
of the program.
}%comp

\notop{%
\item["-pp" \var{command}]
Cause the compiler to call the given \var{command} as a preprocessor
for each source file. The output of \var{command} is redirected to
an intermediate file, which is compiled. If there are no compilation
errors, the intermediate file is deleted afterwards.
}%notop

\item["-ppx" \var{command}]
After parsing, pipe the abstract syntax tree through the preprocessor
\var{command}. The module "Ast_mapper", described in
\ifouthtml
chapter~\ref{c:parsinglib}:
\ahref{compilerlibref/Ast\_mapper.html}{ \texttt{Ast_mapper} }
\else section~\ref{Ast-underscoremapper}\fi,
implements the external interface of a preprocessor.

\item["-principal"]
Check information path during type-checking, to make sure that all
types are derived in a principal way.  When 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 "-principal" mode 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.

\item["-rectypes"]
Allow arbitrary recursive types during type-checking.  By default,
only recursive types where the recursion goes through an object type
are supported. \notop{Note that once you have created an interface using this
flag, you must use it again for all dependencies.}

\notop{%
\item["-runtime-variant" \var{suffix}]
Add the \var{suffix} string to the name of the runtime library used by
the program.  Currently, only one such suffix is supported: "d", and
only if the OCaml compiler was configured with option
"-with-debug-runtime".  This suffix gives the debug version of the
runtime, which is useful for debugging pointer problems in low-level
code such as C stubs.
}%notop

\nat{%
\item["-S"]
Keep the assembly code produced during the compilation. The assembly
code for the source file \var{x}".ml" is saved in the file \var{x}".s".
}%nat

\item["-safe-string"]
Enforce the separation between types "string" and "bytes",
thereby making strings read-only. This is the default, and enforced
since OCaml 5.0.

\item["-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.

\nat{
\item["-save-ir-after" \var{pass}]
Save intermediate representation after the given compilation pass
to a file.
The currently supported passes and the corresponding file extensions are:
"scheduling" (".cmir-linear").

This experimental feature enables external tools to inspect and manipulate
compiler's intermediate representation of the program
using "compiler-libs" library (see
\ifouthtml chapter~\ref{c:parsinglib} and
\ahref{compilerlibref/Compiler\_libs.html}{ \texttt{Compiler_libs} }
\else section~\ref{Compiler-underscorelibs}\fi
).
}%nat

\nat{%
\item["-shared"]
Build a plugin (usually ".cmxs") that can be dynamically loaded with
the "Dynlink" module. The name of the plugin must be
set with the "-o" option. A plugin can include a number of OCaml
modules and libraries, and extra native objects (".o", ".obj", ".a",
".lib" files). Building native plugins is only supported for some
operating system. Under some systems (currently,
only Linux AMD 64), all the OCaml code linked in a plugin must have
been compiled without the "-nodynlink" flag. Some constraints might also
apply to the way the extra native objects have been compiled (under
Linux AMD 64, they must contain only position-independent code).
}%nat

\item["-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. Identifier names starting with an underscore "_" or
containing double underscores "__" incur a penalty of $+10$ when computing
their length.

\top{
\item["-stdin"]
Read the standard input as a script file rather than starting an
interactive session.
}%top

\notop{
\item["-stop-after" \var{pass}]
Stop compilation after the given compilation pass. The currently
supported passes are:
"parsing", "typing"\nat{, "scheduling", "emit"}.
}%notop

\item["-strict-sequence"]
Force the left-hand part of each sequence to have type unit.

\item["-strict-formats"]
Reject invalid formats that were accepted in legacy format
implementations. You should use this flag to detect and fix such
invalid formats, as they will be rejected by future OCaml versions.

\notop{%
\item["-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]".
}%notop

\notop{%
\item["-no-unboxed-types"]
When a type is unboxable  it will be boxed unless annotated with
"[\@\@ocaml.unboxed]". This is the default.
}%notop

\item["-unsafe"]
Turn bound checking off for array and string accesses (the "v.(i)" and
"s.[i]" constructs). Programs compiled with "-unsafe" are therefore
\comp{slightly} faster, but unsafe: anything can happen if the program
accesses an array or string outside of its bounds.
\notop{%
Additionally, turn off the check for zero divisor in integer division
 and modulus operations. With "-unsafe", an integer division
(or modulus) by zero can halt the program or continue with an
unspecified result instead of raising a "Division_by_zero" exception.
}%notop

\item["-unsafe-string"]
Identify the types "string" and "bytes", thereby making strings writable.
This is intended for compatibility with old source code and should not
be used with new software. This option raises an error unconditionally
since OCaml 5.0.

\comp{%
\item["-use-runtime" \var{runtime-name}]
Generate a bytecode executable file that can be executed on the custom
runtime system \var{runtime-name}, built earlier with
"ocamlc -make-runtime" \var{runtime-name}.
See section~\ref{ss:custom-runtime} for more information.
}%comp

\item["-v"]
Print the version number of the compiler and the location of the
standard library directory, then exit.

\item["-verbose"]
Print all external commands before they are executed,
\nat{in particular invocations of the assembler, C compiler, and linker.}
\comp{in particular invocations of the C compiler and linker in "-custom" mode.}
Useful to debug C library problems.

\notop{%
\item["-version" or "-vnum"]
Print the version number of the compiler in short form (e.g. "3.11.0"),
then exit.
}%notop

\top{%
\item["-version"]
Print version string and exit.

\item["-vnum"]
Print short version number and exit.

\item["-no-version"]
Do not print the version banner at startup.
}%top

\item["-w" \var{warning-list}]
Enable, disable, or mark as fatal the warnings specified by the argument
\var{warning-list}.
Each warning can be {\em enabled} or {\em disabled}, and each warning
can be {\em fatal} or {\em 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 \var{warning-list} argument is a sequence of warning specifiers,
with no separators between them.  A warning specifier is one of the
following:

\begin{options}
\item["+"\var{num}] Enable warning number \var{num}.
\item["-"\var{num}] Disable warning number \var{num}.
\item["\@"\var{num}] Enable and mark as fatal warning number \var{num}.
\item["+"\var{num1}..\var{num2}] Enable warnings in the given range.
\item["-"\var{num1}..\var{num2}] Disable warnings in the given range.
\item["\@"\var{num1}..\var{num2}] Enable and mark as fatal warnings in
the given range.
\item["+"\var{letter}] Enable the set of warnings corresponding to
\var{letter}. The letter may be uppercase or lowercase.
\item["-"\var{letter}] Disable the set of warnings corresponding to
\var{letter}. The letter may be uppercase or lowercase.
\item["\@"\var{letter}] Enable and mark as fatal the set of warnings
corresponding to \var{letter}. The letter may be uppercase or
lowercase.
\item[\var{uppercase-letter}] Enable the set of warnings corresponding
to \var{uppercase-letter}.
\item[\var{lowercase-letter}] Disable the set of warnings corresponding
to \var{lowercase-letter}.
\end{options}

Alternatively, \var{warning-list} can specify a single warning using its
mnemonic name (see below), as follows:

\begin{options}
\item["+"\var{name}] Enable warning \var{name}.
\item["-"\var{name}] Disable warning \var{name}.
\item["\@"\var{name}] Enable and mark as fatal warning \var{name}.
\end{options}

Warning numbers, letters and names which are not currently defined are
ignored. The warnings are as follows (the name following each number specifies
the mnemonic for that warning).
\begin{options}
\input{warnings-help.tex}
\end{options}

The default setting is "-w +a-4-6-7-9-27-29-32..42-44-45-48-50-60".
It is displayed by {\machine\ocamlx\ -help}.
Note that warnings 5 and 10 are not always triggered, depending on
the internals of the type checker.


\item["-warn-error" \var{warning-list}]
Mark as fatal the warnings specified in the argument \var{warning-list}.
The compiler will stop with an error when one of these warnings is
emitted. The \var{warning-list} has the same meaning as for
the "-w" option: 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,
and a "\@" sign both enables and marks as fatal the corresponding
warnings.

Note: it is not recommended to use warning sets (i.e. letters) as
arguments to "-warn-error"
in production code, because this can break your build when future versions
of OCaml add some new warnings.

The default setting is "-warn-error -a+31" (only warning 31 is fatal).

\item["-warn-help"]
Show the description of all available warning numbers.

\notop{%
\item["-where"]
Print the location of the standard library, then exit.
}%notop

\notop{%
\item["-with-runtime"]
Include the runtime system in the generated program. This is the default.
}

\notop{%
\item["-without-runtime"]
The compiler does not include the runtime system (nor a reference to it) in the
generated program; it must be supplied separately.
}

\item["-" \var{file}]
\notop{Process \var{file} as a file name, even if it starts with a dash ("-")
character.}
\top{Use \var{file} as a script file name, even when it starts with a
hyphen (-).}

\item["-help" or "--help"]
Display a short usage summary and exit.

\end{options}
%