Opam Switch to Multicore OCaml25 Mar 2015
OPAM has a great compiler
switch feature that lets you
simultaneously host several OCaml installations, each with its own compiler
version and a set of installed packages. I wanted to use the power of
switch for working with the experimental multicore
OCaml compiler. The key
advantage of doing this is that it lets you easily install packages from the
OPAM repository, while sandboxing it from other OCaml
installations on your system. The post will show how to create OPAM compiler
switch for multicore OCaml.
The first step is to install Gabriel Scherer’s opam-compiler-conf script which lets you do opam switches on local installations:
This installs the
opam-compiler-conf script under
~/.local/bin. Make sure
this directory is under your search path. Now,
$opam compiler-conf should
give you the list of available commands.
Build multicore OCaml locally
opam switch should list the compilers currently installed in your
system and those that are available. For instance, here is my setup:
You can easily switch between the installations using
[system-name]. Let us now install multicore OCaml as a new switch:
The multicore compiler is now installed and has been made the current compiler:
This can be confirmed by:
which shows the current OCaml bytecode compiler version.
Working with the local switch
Every time you change the compiler source, you need to rebuild the compiler and reinstall the switch:
The local installation can be removed by
opam compiler-conf uninstall.