Skip to content

Latest commit

 

History

History
102 lines (76 loc) · 4.8 KB

ocamlc.org

File metadata and controls

102 lines (76 loc) · 4.8 KB

Intorduction

ocamltoplevel top
ocamlrunbytecode interpreter
ocamlcbytecode batch compiler
ocmaloptnative code batch compiler
ocamlc.optoptimized bytecode batch compiler
ocamlopt.optoptimized native code batch compiler
ocamlmktoptoplevel constructor

The optimized compilers are themselves compiled with the Objective Caml native compiler. They compile faster but are otherwise identical to their unoptimized counterparts.

Compilation Unit: For the interactive system, the unit of compilation corresponds to a phrase of the language. For the batch compiler, the unit of compilation is two files: the source file, and the interface file. The compiled interface is used for both the bytecode and native code compiler.

mlsource
mliinterface
cmicompiled interface
cmoobject file(byte)
cmalibrary object file (byte)
cmxobject file (native)
cmxalibrary object file(native)
cc source
oc object file (native)
ac library object file(native)

The options

-aconstruct a runtime Library
-annotsave information in <filename>.annot
-ccompile without linking
-o namespecify the name of the exetuable
-linkalllink with all libraries
-idisplay all compiled global declarations, generate .mli file
-pppreprocessor
-vdisplay version
-unsafeturn off index checking
-w listchoose among the list the level of the warning messages
-impl fileindicate that file is a caml source
-intf file
-output-objoutput = a c object file instead of an executable
-I diradd directory in the list of directores
-threadgenerate code that supports the threads library
-gsave debugging information
-noassertDo not compile asssertion checks
-customlink in custom mode
-cclib <opt>pass option <opt> to the c linker
-ccopt <opt>pass <opt> to the c compiler and c linker
-make-runtimeBuilding a runtime system with given c objects and libraries
-use-runtimeGenerate bytecode for the given runtime system
-vmthreadVM-level thread support
-dparsetreegenerate the parse output
-drawlambda
-dlambda
-dinstr

For the warnings

A/aenable/disable all messages
F/fpartial application in a sequence
P/pincomplete pattern matching
U/umissing cases in pattern matching
X/xenable/disable all other messages
M/m V/vfor hidden object

About warning messages, the compiler chooses the A by default. turn off some warnings sometimes is helpful, for example

ocamlbuild -cflags -w,aPF top_level.cma      

Here are some options for ocamlopt

-compactoptiize the produced code for space
-Skeeps the assembly code in a file
-inline levelset the aggressiveness of inlining