Previous Up Next

Chapter 4  JoCaml Tools

4.1  A few words on implementation(s)

The JoCaml system is structured as the Objective Caml system, with a bytecode compiler jocamlc and a native-code compiler jocamlopt. In fact, JoCaml is a modified Objective Caml. The JoCaml compilers translate Join constructs into function calls to an ad-hoc library. The ad-hoc library is an extension of the thread library of Objective Caml, which we simply call the threads library. The threads library comes in two flavors: virtual-machine level threads and system-level threads. JoCaml uses system-level threads by default. As a result of its design, JoCaml inherits the limitations of Objective Caml thread implementations. In particular, there can be at most one thread actually executing at a time, even on multi-core machines.

The compilers jocamlc and jocamlopt should be binary compatible with Objective Caml. More precisely, while installing JoCaml, a “companion Objective Caml” is defined — see file INSTALL in the distribution for details. The companion system must have the same version number as the JoCaml system. Then, the search paths for the compiler are completed by the ones of the companion system. For that reason JoCaml distribution includes a limited subset of Objective Caml libraries.

4.2  Summary of tool modifications

All JoCaml tools are Objective Caml tools with an initial “j”: jocamlc jocaml etc.

jocamlc
The bytecode compiler. By default, jocamlc assumes compilation with respect to the system threads library. In that aspect, it behaves like ocamlc with command line options -thread, with libraries unix.cma and threads.cma added at link time.

New or modified options are:

-v
Print the version number of the compiler, the location of the standard library directory and the location of the companion Objective Caml, if any; then exit.
-nojoin
Act as an Objective Caml compiler as much as possible:
  • Do not recognize the keywords that are specific to JoCaml (def, spawn and reply).
  • Cancel the effect of -thread and -vmthread.
  • Suppress implicit link arguments unix.cma and thread.cma.
This option is useful mostly for system bootstrap.
-thread (resp. -vmthread)
Compile or link multithreaded programs, in combination with the system (resp. virtual-machine level) threads library. By contrast with ocamlc, -thread is the default.
jocaml
The interactive toplevel. By defaults this toplevel includes the system-level threads library and the unix library.
jocamlrun
The JoCaml virtual machine that executes bytecode files produced by jocamlc. C shared library are searched as ocamlrun does with an additional step beetween step 4. and 5.
4-bis.
Directories specified in the file ld.conf of companion Objective Caml standard library directory, if any.
jocamlopt
The native-code compiler. Added or modified options are the same as for jocamlc, except for the -vmthread option which does not exist.
jocamllex and jocamlyacc
Lexer and parser generators. Those two tools are unchanged, except for their names.
jocamldep
The dependency generator. The jocamldep progam accepts JoCaml sources as input. This default behavior can be changed by the following option:
-nojoin
Act over pure Objective Caml files.
jocamlmklib
The tool to build mixed C/JoCaml libraries. There are two additional (cosmetic) options:
-jocamlc cmd
Alias for -ocamlc cmd.
-jocamlopt cmd
Alias for -oocamlopt cmd.
jocamlmktop
The tool for building custom toplevels. The produced toplevels accept and execute JoCaml source code.

4.3  Using ocamlbuild

Objective Caml compilation manager, ocamlbuild, is able to handle simple JoCaml projects: it suffice to add command-line option “-use-jocaml”. Then, ocamlbuild will use JoCaml tools in place of Objective Caml tools.


Previous Up Next