opam-repository
opam-repository copied to clipboard
ocaml-base-compiler < 4.14.1 is not compatible with llvm-ranlib < 16.0.0
I got this failure when running opam init
for the first time. I have an x86 Macbook Pro, running macOS Monterey Version 12.2.1. The error message prompted me to file a new bug report.
$ opam init
No configuration file found, using built-in defaults.
Checking for available remotes: rsync and local, git.
- you won't be able to use mercurial repositories unless you install the hg command on your system.
- you won't be able to use darcs repositories unless you install the darcs command on your system.
<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><> 🐫
[default] Initialised
<><> Required setup - please read <><><><><><><><><><><><><><><><><><><><><> 🐫
In normal operation, opam only alters files within ~/.opam.
However, to best integrate with your system, some environment variables
should be set. If you allow it to, this initialisation step will update
your zsh configuration by adding the following line to ~/.zshrc:
[[ ! -r /Users/colegranof/.opam/opam-init/init.zsh ]] || source /Users/colegranof/.opam/opam-init/init.zsh > /dev/null 2> /dev/null
Otherwise, every time you want to access your opam installation, you will
need to run:
eval $(opam env)
You can always re-run this setup with 'opam init' later.
Do you want opam to modify ~/.zshrc? [N/y/f]
(default is 'no', use 'f' to choose a different file) y
User configuration:
Updating ~/.zshrc.
<><> Creating initial switch 'default' (invariant ["ocaml" {>= "4.05.0"}] - initially with ocaml-base-compiler)
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><> 🐫
Switch invariant: ["ocaml" {>= "4.05.0"}]
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
∗ installed ocaml-options-vanilla.1
⬇ retrieved ocaml-base-compiler.4.14.0 (https://opam.ocaml.org/cache)
[ERROR] The installation of ocaml-base-compiler failed at "make install".
#=== ERROR while installing ocaml-base-compiler.4.14.0 ========================#
# context 2.1.2 | macos/x86_64 | | https://opam.ocaml.org#29b5fe8a
# path ~/.opam/default/.opam-switch/build/ocaml-base-compiler.4.14.0
# command ~/.opam/opam-init/hooks/sandbox.sh install make install
# exit-code 2
# env-file /var/folders/wx/b_7fpb8j28g0wb809tlggtt40000gn/T/opam-colegranof-5217/ocaml-base-compiler-5217-60d107.env
# output-file /var/folders/wx/b_7fpb8j28g0wb809tlggtt40000gn/T/opam-colegranof-5217/ocaml-base-compiler-5217-60d107.out
### output ###
# /usr/bin/install -c -m 644 \
# [...]
# /usr/bin/install -c -m 644 \
# driver/main.cmx driver/main.o \
# driver/optmain.cmx driver/optmain.o \
# toplevel/topstart.o \
# "/Users/colegranof/.opam/default/lib/ocaml/compiler-libs"
# cd "/Users/colegranof/.opam/default/lib/ocaml/compiler-libs" && \
# ranlib ocamlcommon.a ocamlbytecomp.a ocamloptcomp.a
# ranlib: error: exactly one archive should be specified
# make[2]: *** [installoptopt] Error 1
# make[1]: *** [installopt] Error 2
# make: *** [install] Error 2
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
┌─ The following actions failed
│ ∗ install ocaml-base-compiler 4.14.0
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray base
│ ∗ install base-threads base
│ ∗ install base-unix base
│ ∗ install ocaml-options-vanilla 1
└─
<><> ocaml-base-compiler.4.14.0 troubleshooting <><><><><><><><><><><><><><> 🐫
=> A failure in the middle of the build may be caused by build parallelism
(enabled by default).
Please file a bug report at https://github.com/ocaml/opam-repository/issues
=> You can try installing again including --jobs=1
to force a sequential build instead.
# Run eval $(opam env --switch=default) to update the current shell environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] Y
[NOTE] Opam has been initialised, but the initial switch creation failed.
Use 'opam switch create <compiler>' to get started.
This is fixed in OCaml 5 in https://github.com/ocaml/ocaml/pull/11184.
I believe this can be worked around on macOS by installing GNU binutils?
@dra27 did you mean uninstalling instead?
Usually this failure is fixed by brew unlink binutils
Oh, I see - I'd misremembered the problem!
Same problem under OpenBSD: llvm-ranlib
is default ranlib
and processes archive files one at a time. Success with a ranlib
wrapper
for file in "$@"
do
/usr/bin/ranlib $file
done
I suggest also fixing it for OCaml 4.14.1, since OCaml 5 has compatibility issues.
I'm sorry that we didn't report the problem to upstream yet. We've had a local patch in our (OpenBSD) ports tree since March...
and yeah, we're still on ocaml 4.x as well.
upgrading ocaml to a newer version almost always mean that some other ports using ocaml will break. This thing is already brittle for minor versions.
I shudder to think about the compatibility issues in version 5.
Same problem under OpenBSD:
llvm-ranlib
is defaultranlib
and processes archive files one at a time.
Is that a new default? OpenBSD 7.0 works fine out-of-the-box
ah, it's in 7.1. I see. Well, i can see a few solutions:
- we could mark all ocaml-base-compiler packages not available on OpenBSD >= 7.1 and just wait for either OCaml 4.14.1 or a release of OpenBSD with llvm 16.0.0 (see https://github.com/llvm/llvm-project/commit/aa173573198e024b065c5f6523ce26bb865781b7) (easy)
- we could patch the hundreds of compiler packages to add the ranlib wrapper on OpenBSD (tedious)
- or maybe add some sort of warning
OpenBSD doesn't like GPL, so when the llvm tools become viable we switch. I haven't followed closely the move from binutils, but yeah, we stopped installing ranlib from binutils sometime fairly recently, on some architectures.
We never followed the FSF projects into GPLv3, which mean we got stuck with an antiquated gcc (somewhere after 4.2) and an antiquated binutils/gdb until llvm became viable. (lldb is not quite there yet).
actually, I'm stupid, I can date the switch very specifically, from the ocaml patch in the ports tree.
date: 2022/03/24 14:39:17; author: robert; state: Exp; commitid: QNcqrKEnawQ6nRp9;
unbreak after switching llvm-ranlib; it only takes one archive at a time
the switch occurred less than a week before that. Since we have one release in may and one in november, it was present in the last release and obviously in all snapshots.
ah, it's in 7.1. I see. Well, i can see a few solutions:
- we could mark all ocaml-base-compiler packages not available on OpenBSD >= 7.1 and just wait for either OCaml 4.14.1 or a release of OpenBSD with llvm 16.0.0 (see llvm/llvm-project@aa17357) (easy)
- we could patch the hundreds of compiler packages to add the ranlib wrapper on OpenBSD (tedious)
- or maybe add some sort of warning
Thanks for sleuthing that one.
It's very unlikely we're going to switch to llvm 16.0 quickly (lots of testing involved as you can imagine), but I will ask about cherry-picking that change!