It is my great pleasure, 3 years to the day since I finalised the first full demonstration of it in Ljubljana for the OCaml Workshop in 2022, to announce the general availability of Relocatable OCaml for testing and review.
For example, this creates a 5.4.0 switch (the good old-fashioned slow way):
$ time opam switch create --repos=relocatable=git+https://github.com/dra27/opam-repository.git#relocatable,default original-compiler ocaml.5.4.0
real 1m27.646s
But, having run that, subsequent switches are a just a tad quicker:
$ eval $(opam env)
$ ocamlopt -where
/home/opam/.opam/original-compiler/lib/ocaml
$ time opam switch create . --repos=relocatable,default ocaml.5.4.0
real 0m5.105s
$ eval $(opam env)
$ ocamlopt -where
/home/opam/myproject/_opam/lib/ocaml
And, um, that’s it really!
Oh, there are a few other things bundled into the relocatable branch on dra27/opam-repository:
- It’s available for all versions of OCaml since 4.08. They install using their “trunk” versions - i.e. the version number of what would be the next release of OCaml (4.08.2, 4.09.2, 4.10.3, 4.11.3, 4.12.2, 4.13.2, 4.14.3, 5.0.1, 5.1.2, 5.2.2, 5.1.3, pre-release 5.4.0 and, for completeness, trunk OCaml is present as 5.5.0)
- Relocatable versions of
ocamlbuildandocamlfindare included, along with patches foromodandstdcompat - The
ocaml-option-packages work for all of the older versions, too - They all work on Windows (including 4.08-4.12, which aren’t yet available in opam-repository)
- They all work on Apple silicon (including 4.08, 4.09 and 4.11)
I have literally just opened the PRs on ocaml/ocaml (ocaml/ocaml#14243, ocaml/ocaml#14244, ocaml/ocaml#14245 and ocaml/ocaml#14246). In the interests of those of us who maintain libraries and tools which have to target multiple versions of OCaml, there will be some kind of story for keeping these older versions available, but the focus for now will be reaching a consensus for merging the feature itself into OCaml 5.5.
Please do test and report any issues at GitHub · Where software is built. Over-zealous lock-file systems notwithstanding, the compiler should be as “drop-in” a replacement as updating to any “point release” of the compiler (i.e. if you have something which works in OCaml 5.3.0 but doesn’t work in Relocatable OCaml 5.3.1, that’s a bug, and I’d love to hear about it a.s.a.p., please!)