Reproducible builds across different architectures

I have been using opam lock and the --locked option of opam pin to get reproducible builds across my home environment and my CI. However, one problem I am having is that my home computer has a different architecture than my CI. In particular, on my home machine (where I generated the lockfile), I have host-arch-arm64 installed and on my CI, there appears to be host-arch-x86_64. For this reason, the package cannot be built from the lockfile on the CI.

Is there a standard way to deal with this problem? And my apologies if I am misunderstanding some aspect of how this all works, or the boundaries between opam and the OCaml compiler.

1 Like

Ah, this is an unintended consequence of the merge of Update ocaml-base-compiler, ocaml-system and ocaml-variants 4.13.0+ with support for native Windows by dra27 · Pull Request #25861 · ocaml/opam-repository · GitHub, so there isn’t yet a standard mechanism for this.

As it happens, this kind of use of opam lock has been “broken” for a while - as implemented, opam lock allows dependency sharing between basically identical machines. This has already been known for a while to fail once you have OS-specific dependencies; the change has unfortunately made it a rather trivial issue to hit.

I think the way forward for now may be to back out the use of the arch- and system- packages for non-Windows systems, until a proper mechanism is available in opam (there are various ideas in flight).

As a workaround, I think removing the arch- and system- packages from the lock should work.

2 Likes

About reproducibility, you should check orb (and this little tutorial). You can easily test the reproducibility of an executable as bob.

1 Like

@dinosaure I did not see your response, but thank you for sharing this… It looks very interesting and I hope to study it in more detail once I have a bit of time in August.