TL;DR: ocaml PR compiler switches in opam are moving to their own dedicated git remote
It can be convenient to quickly try out a proposed patch to the OCaml compiler and rapidly get a package development environment up and running, without having to manually recompile everything. So far, this has been done via a script that directly adds the GitHub PRs into the mainline opam-repository.
However, as OCaml grows in popularity so do the number of PRs, and the new opam2 repository format is having some trouble coping with the sheer number of compiler variants. Therefore, we are now moving the many-small-compiler-variants into their own remote repository that can be optionally added if you want this functionality.
ocaml/ocaml-pr-repository contains a set of opam1-format compiler descriptions that are dynamically generated daily from the list of active PRs in the OCaml GitHub repository. They let you switch to any active PR using the opam package manager very easily:
Usage
First add the repository to your opam package universe:
And that’s all you need to do to use the patched compiler. Once you have tested the patch, don’t forget to comment on the pull request with anything you’ve learnt from the usage of the patch.
IIRC, @dra27 was working on having options inside packages, which would allow to merge all the +fp/alf/… variants and further decrease the number of superfluous compilers. What’s the situation on that?
Question: does the fact that opam 2 treats compilers as packages mean that it should be able to provide you with the set of compilers capable of supporting a particular set of packages, so you don’t have to keep trying one compiler version after another? This is one of the pain points of opam 1.
The scenario is the following: I want to install packages X, Y and Z. I install the latest opam switch, followed by X. Now I want to install Y, and it turns out the Y that is compatible with X is not compatible with the current version of OCaml. I try an earlier opam switch, reinstall X and Y, and when I get to Z, it turns out that the version of Z compatible with Y isn’t compatible with the version of OCaml I’m using now. So I try a different opam switch and the process continues.
I’d like to simplify this process so that installing X, Y and Z will also suggest the matching, latest version of OCaml. If I install package R which is incompatible with that version of OCaml, it’ll switch me to a version compatible with all the packages I have + R (if such an OCaml version exists).
EDIT: of course, opam should do everything for me, so when it switches me to another ocaml version, it should also reinstall all my existing packages.
opam switch create thingy --empty --descr "The thingy compiler"
opam install \
ocaml-base-compiler \ # Forces a vanilla compiler. not really needed
packageX packageY packageZ
# The solver should find a most up-to-date solution which includes the compiler.
# This might take a little bit of time, both solving and compiling.
opam switch set-base ocaml # Fixes the version of the compiler for normal upgrades
...
# Now you want to upgrade the compiler to a new version:
opam upgrade ocaml --unlock
This workflow also applies to non-standard compilers such as metaocaml. With opam 2, we will also be able to add constraints such as “this libraries needs a compiler providing modular implicits” fairly easily, which could help with experimentation.