opam install core_unix fails on Linux
When running opam install core_unix, it fails to build properly on my Linux computer.
Ocaml version:
❯ pacman -Q | rg ocaml
ocaml 5.3.0-1
ocaml-compiler-libs 5.3.0-1
❯ opam --version
2.3.0
❯ ocaml --version
The OCaml toplevel, version 5.3.0
❯ dune --version
3.17.2
❯ opam install core_unix
The following actions will be performed:
=== install 1 package
- install core_unix v0.17.0
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> retrieved core_unix.v0.17.0 (cached)
[ERROR] The compilation of core_unix.v0.17.0 failed at "dune build -p core_unix -j 23".
#=== ERROR while compiling core_unix.v0.17.0 ==================================#
# context 2.3.0 | linux/x86_64 | ocaml.5.3.0 | https://opam.ocaml.org#717e57b54bb7da8f42974d56f9408e807e4a154f
# path ~/.opam/default/.opam-switch/build/core_unix.v0.17.0
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p core_unix -j 23
# exit-code 1
# env-file ~/.opam/log/core_unix-711963-319d47.env
# output-file ~/.opam/log/core_unix-711963-319d47.out
### output ###
# /usr/lib/ocaml/caml/platform.h:222:10: error: implicit declaration of function 'atomic_load_acquire' [-Wimplicit-function-declaration]
# [...]
# | ^~~~~~~~~~~~~~~~~~~
# /usr/lib/ocaml/caml/platform.h: In function 'caml_plat_latch_set':
# /usr/lib/ocaml/caml/platform.h:230:3: error: implicit declaration of function 'atomic_store_release'; did you mean 'atomic_store_explicit'? [-Wimplicit-function-declaration]
# 230 | atomic_store_release(&latch->value, Latch_unreleased);
# | ^~~~~~~~~~~~~~~~~~~~
# | atomic_store_explicit
# (cd _build/default && /usr/bin/ocamlopt.opt -w -40 -g -I time_float_unix/time_unix/.time_unix.objs/byte -I time_float_unix/time_unix/.time_unix.objs/native -I /home/anon/.opam/default/lib/base -I /home/anon/.opam/default/lib/base/base_internalhash_types -I /home/anon/.opam/default/lib/base/md5 -I /home/anon/.opam/default/lib/base/shadow_stdlib -I /home/anon/.opam/default/lib/base_bigstring -I[...]
# File "time_float_unix/time_unix/time_unix.ml", line 1, characters 4-14:
# 1 | [@@@deprecated "[since 2022-04] Use [Time_float_unix] instead"]
# ^^^^^^^^^^
# Warning 53 [misplaced-attribute]: the "deprecated" attribute cannot appear in this context
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build core_unix v0.17.0
+-
- No changes have been performed
In my system, adding
#include <isc/atomic.h>
to platform.h solved the problem. (This header is part of the bind package.)
Configuration:
$ inxi -xS
System:
Host: shirin Kernel: 6.12.4-1-MANJARO arch: x86_64 bits: 64 compiler: gcc
v: 14.2.1
Desktop: Xfce v: 4.20.0 Distro: Manjaro base: Arch Linux
$ opam switch
# switch compiler description
-> default ocaml-base-compiler.5.3.0,ocaml-options-vanilla.1 ocaml >= 4.05.0
I'm getting the same error.
This may be a regression in OCaml actually. If you change to an OCaml 5.2.1 switch, core_unix install succeeds.
Related issue: https://github.com/janestreet/core_unix/issues/14
This may be a regression in OCaml actually. If you change to an OCaml 5.2.1 switch, core_unix install succeeds.
Thanks, this fixed it. After following your link to issue #14, I see that it was a bigger issue. Thanks for pointing this out here, otherwise I wouldn't have found that.