The OCaml compiler can produce two kinds of executables: bytecode and native. Native executables (produced by the compiler ocamlopt) are generally faster than bytecode executables since they are compiled specifically for an architecture. Bytecode executables (produced by the compiler ocamlc) have the advantage of being portable, which means that a bytecode executable can be run on any architecture without having to be recompiled. Bytecode executables are smaller than native code executables. If considering only one process the advantage in size is annihilated by the need for the OCaml run time system for executing bytecode, however there is an advantage when running several bytecode processes in parallel since the runtime system can then be shared. It should be noted that OCaml compilers to native code are not provided for every architecture. Only the following ones are supported: amd64, i386, kfreebsd-i386, powerpc, sparc.
Packages providing both native and bytecode versions of a program prog usually name them respectively prog.opt and prog.byte and provide a symbolic link prog to the best available version (generally prog.opt).
The ocaml-native-compilers package contains the OCaml compiler executables built in native mode: ocamlc.opt, which produces bytecode, and ocamlopt.opt, which produces native code. Since the OCaml compilers are themselves written in OCaml this package exists only on architectures where compilation to native code is supported.
The ocaml-nox package contains the OCaml compiler executables built in bytecode mode: ocamlc, which produces bytecode, and on architectures where compilation to native code is supported the compiler ocamlopt, which produces native code. It is important to understand that on architectures where compilation to native code is supported both packages contain compilers from OCaml to both bytecode and native code, the difference lies in the nature (installation size and execution speed) of the compiler executables.
Table 1-1. OCaml Compilers
|Compiles to bytecode||Compiles to native code|
|Compiler executable in bytecode||ocamlc||ocamlopt|
|Compiler executable in native code||ocamlc.opt||ocamlopt.opt|
Compiling with native code versions of the compilers is generally faster than with compilers in bytecode. Unfortunately, the ocaml-native-compilers package is not available on every architecture. Packages should therefore never depend directly on this package. In order to build big programs and benefit from this natively built compiler, packages should depend on ocaml-best-compilers which itself depends on ocaml-native-compilers where available and on ocaml elsewhere. Since it is a virtual package, it cannot (yet) be a versioned dependency. The version dependency should thus be carried by the ocaml dependency. Note that dependency on ocaml-best-compilers is only necessary for real big programs for which compilation takes a lot of resources. For most small programs the compilers from the ocaml-nox package are perfectly sufficient, and faster to install in a build environment than compiler executables in native code.