Opam compiler PRs are migrating to their own remote

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:

$ opam repo add ocaml-pr https://github.com/ocaml/ocaml-pr-repository.git

Then list all the available compilers to find your PR

$ opam switch --all
[...]
-- 4.06.0+pr944                  Added some missing numeric C99-functions to Pervasives
-- 4.06.0+pr964                  Add Pervasives.pi
-- 4.06.0+pr974                  Enable msvc64 asmcomp tests
-- 4.06.0+pr975                  Make the testsuite more paranoid about the results
-- 4.06.0+trunk+afl              4.06 release branch with afl-fuzz instrumentation
-- 4.06.0+trunk+flambda          4.06 release branch with flambda activated
-- 4.06.0+trunk+fp               4.06 release branch with frame-pointers

Then switch to the PR you want to try out:

$ opam switch 4.06.0+pr944
$ eval `opam config env`

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.

2 Likes

Finally! :wink:

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?

Still work in progress - and also for opam 2 only

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.

I’m afraid I don’t understand the question. Could you give a slightly more detailed example of the problem you are trying to solve?

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.

@bluddy Yes, what you expect works:

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.

4 Likes