Date Tags ocaml

The dose3 code base is getting larger and larger and waiting 40 secs each time I want to recompile the library is not acceptable anymore. Recently I tried to understand why the ocaml compiler was so slow .

To compile dose, I use a combination of ocamlbuild, ocamlfind, camlp4 and Makefile to drive everything.

The first important problem was related to my naive use of camlp4. I extensively use the Camlp4MacroParser module for the conditional compilation of certain features and actually I use camlp4 to process all my source code. The bottom line her is that using the byte code version of camlp4o is definitely a bad idea.

To use the native binary you need to change the pre-processing directive in the file _tags :

<*/*.ml{i,}>: pp(camlp4o.opt -I_build Camlp4MacroParser.cmxs)

This will use the opt version of camlp4 and the cmxs instead of the .cma. The next problem is that debian, for some reason (I guess lack of time, more then anything else), does not ship the cmxs libraries of the Camlp4MacroParser. In other to make this available, I added a simple compilation rule in my make file to create the file Camlp4MacroParser.cmxs in the _build directory.

 ocamlopt -shared $(shell ocamlc -where)/camlp4/Camlp4Parsers/Camlp4MacroParser.cmx -o _build/Camlp4MacroParser.cmxs

The second BIG problem I solved yesterday was related to the tag traverse. Since I use git as VCS, every invocation to ocamlbuild was triggering a recursive traverse of all the .git directory with a considerable waste of time.

To solve this problem, I’ve reverted the default ocamlbuild and explicitly add only those directory that I’m really interested to traverse.

true: -traverse
<{common,algo,doseparse,deb,rpm,applications,experimental}/**>: traverse

This is actually needed not to compile the code itself, but to generate the documentation with ocamldoc.