ERROR while compiling ocaml-variants.4.12.0+domains+effects

I’m encountering the followiong error on Ubuntu 24.04 for ARM64 architecture.

$ uname
Linux taulecgw 6.8.0-1021-azure #25-Ubuntu SMP Wed Jan 15 20:23:05 UTC 2025 aarch64 aarch64 aarch64 GNU/Linux

In this environment, I did the following
[1] bash -c "sh <(curl -fsSL https://opam.ocaml.org/install.sh)"
(according to Install OCaml)
[2] opam init --yes
[3] eval $(opam env); opam install jupyter --yes

Then I got this error (I attached the whole log):

#=== ERROR while compiling ocaml-variants.4.12.0+domains+effects ==============#
# context     2.3.0 | linux/arm64 |  | https://opam.ocaml.org#a8ed476033bb6d4d29d63b5907404e6ef35a302d
# path        ~/.opam/default/.opam-switch/build/ocaml-variants.4.12.0+domains+effects
# command     /usr/bin/make -j1
# exit-code   2
# env-file    ~/.opam/log/ocaml-variants-213939-0bd9ab.env
# output-file ~/.opam/log/ocaml-variants-213939-0bd9ab.out
### output ###
# [...]
# fiber.c: In function ‘caml_maybe_expand_stack’:
# fiber.c:235:53: error: ‘Wosize_gc_regs’ undeclared (first use in this function
)
#   235 |     value* bucket = caml_stat_alloc(sizeof(value) * Wosize_gc_regs);
#       |                                                     ^~~~~~~~~~~~~~ 
# fiber.c:235:53: note: each undeclared identifier is reported only once for eac
h function it appears in
# make[3]: *** [Makefile:378: fiber.n.o] Error 1
# make[3]: Leaving directory '/home/u25998/.opam/default/.opam-switch/build/ocaml-variants.4.12.0+domains+effects/runtime'

FWIW, I searched ~/.opam/default/.opam-switch/build/ocaml-variants.4.12.0+domains+effects for Wosize_gc_regs and found that it is defined in ~/.opam/default/.opam-switch/build/ocaml-variants.4.12.0+domains+effects/runtime/caml/stack.h when TARGET_amd64 is set and not defined otherwise, which suggests this code only works for amd64 arch.

 ... (cases for other archs omitteed) ...
 
#ifdef TARGET_amd64
/* Size of the gc_regs structure, in words. See amd64.S and amd64/proc.ml for t\
he indices */
#define Wosize_gc_regs (13 /* int regs */ + 16 /* float regs */)
#define Saved_return_address(sp) *((intnat *)((sp) - 8))
#endif

#ifdef TARGET_arm64
#define Saved_return_address(sp) *((intnat *)((sp) - 8))
#define Context_needs_padding /* keep stack 16-byte aligned */
#endif

#ifdef TARGET_riscv
#define Saved_return_address(sp) *((intnat *)((sp) - 8))
#define Callback_link(sp) ((struct caml_context *)((sp) + 16))
#endif
 ...

I also noticed that installing jupyter package has an effect of removing a number of packages (below), so I am a bit worrying if jupyter is an outdated package.

│ ⊘ remove  base-domains          base
│ ⊘ remove  base-effects          base
│ ⊘ remove  base-nnp              base
│ ⊘ remove  ocaml                 5.3.0
│ ⊘ remove  ocaml-base-compiler   5.3.0
│ ⊘ remove  ocaml-compiler        5.3.0
│ ⊘ remove  ocaml-config          3
│ ⊘ remove  ocaml-options-vanilla 1

I have been using opam jupyter package on amd64 architecture for years and this time I tried to switch to ARM64. If there is an alternative to installing opam jupyter package for using Jupyter + OCaml, I won’t stick to the way I am acustomed to.

---------------- the whole log ----------------------

u25997@taulecgw:~$ opam init --yes
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.

[ERROR] Sandboxing is not working on your platform ubuntu:
        "~/.opam/opam-init/hooks/sandbox.sh build sh -c echo SUCCESS | tee
        check-write" exited with code 1 "bwrap: loopback: Failed RTM_NEWADDR:
        Operation not permitted"
Do you want to disable it?  Note that this will result in less secure package
builds, so please ensure that you have some other isolation mechanisms in
place (such as running within a container or virtual machine). [y/n] y

<><> 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 bash configuration by adding the following line to ~/.bash_profile:

    test -r '/home/u25997/.opam/opam-init/init.sh' && . '/home/u25997/.opam/opam-init/init.sh' > /dev/null 2> /dev/null || true

  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.

[WARNING] Shell not updated in non-interactive mode: use --shell-setup

<><> 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-config.3  (2 extra sources)
⬇ retrieved ocaml-config.3  (2 extra sources)
⬇ retrieved ocaml-compiler.5.3.0  (https://opam.ocaml.org/cache)
∗ installed ocaml-compiler.5.3.0
∗ installed ocaml-base-compiler.5.3.0
∗ installed ocaml-config.3
∗ installed ocaml.5.3.0
∗ installed base-domains.base
∗ installed base-effects.base
∗ installed base-nnp.base
Done.
# To update the current shell environment, run: eval $(opam env
--switch=default)
u25997@taulecgw:~$ opam install --yes jupyter 
The following actions will be performed:
=== remove 3 packages
  ⊘ ocaml-base-compiler   5.3.0                  [conflicts with ocaml-config]
  ⊘ ocaml-compiler        5.3.0
  ⊘ ocaml-options-vanilla 1
          [conflicts with ocaml-option-nnp]
=== downgrade 2 packages
  ↘ ocaml                 5.3.0 to 4.12.0        [required by jupyter]
  ↘ ocaml-config          3 to 2                 [required by ocaml]
=== recompile 3 packages
  ↻ base-domains          base                   [uses ocaml-variants]
  ↻ base-effects          base                   [uses ocaml-variants]
  ↻ base-nnp              base
          [uses ocaml-option-nnp, base-domains]
=== install 40 packages
  ∗ base                  v0.15.1                [required by ppx_yojson_conv]
  ∗ base-bytes            base                   [required by ocplib-endian]
  ∗ base64                3.5.1                  [required by jupyter]
  ∗ conf-gmp              4
          [required by conf-gmp-powm-sec, zarith]
  ∗ conf-gmp-powm-sec     3                      [required by cryptokit]
  ∗ conf-pkg-config       4
          [required by zarith, conf-zlib, conf-zmq]
  ∗ conf-zlib             1                      [required by cryptokit]
  ∗ conf-zmq              0.1                    [required by zmq]
  ∗ cppo                  1.8.0                  [required by ppx_deriving]
  ∗ cryptokit             1.20                   [required by jupyter]
  ∗ csexp                 1.5.2
          [required by dune-configurator]
  ∗ dune                  3.17.2                 [required by jupyter]
  ∗ dune-configurator     3.17.2                 [required by cryptokit, zmq]
  ∗ jupyter               2.8.3
  ∗ logs                  0.7.0                  [required by jupyter]
  ∗ lwt                   5.9.1                  [required by jupyter]
  ∗ lwt_ppx               5.9.1                  [required by jupyter]
  ∗ ocaml-compiler-libs   v0.12.4                [required by ppxlib]
  ∗ ocaml-option-nnp      1                      [required by ocaml-variants]
  ∗ ocaml-variants        4.12.0+domains+effects [required by ocaml]
  ∗ ocamlbuild            0.16.1                 [required by logs, uuidm]
  ∗ ocamlfind             1.9.8
          [required by ppx_deriving, logs, uuidm]
  ∗ ocplib-endian         1.2                    [required by lwt]
  ∗ octavius              1.2.2                  [required by ppx_js_style]
  ∗ ppx_derivers          1.2.1                  [required by ppx_deriving]
  ∗ ppx_deriving          6.0.3                  [required by jupyter]
  ∗ ppx_js_style          v0.15.0                [required by ppx_yojson_conv]
  ∗ ppx_yojson_conv       v0.15.1                [required by jupyter]
  ∗ ppx_yojson_conv_lib   v0.15.0                [required by ppx_yojson_conv]
  ∗ ppxlib                0.35.0
          [required by ppx_deriving, lwt_ppx, ppx_yojson_conv]
  ∗ seq                   base                   [required by yojson]
  ∗ sexplib0              v0.15.1                [required by ppxlib, base]
  ∗ stdint                0.7.2                  [required by jupyter]
  ∗ stdlib-shims          0.3.0                  [required by ppxlib]
  ∗ topkg                 1.0.8                  [required by logs, uuidm]
  ∗ uuidm                 0.9.8                  [required by jupyter]
  ∗ yojson                2.2.2                  [required by jupyter]
  ∗ zarith                1.14                   [required by cryptokit]
  ∗ zmq                   5.3.0                  [required by jupyter]
  ∗ zmq-lwt               5.3.0                  [required by jupyter]

<><> Processing actions ><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⊘ removed   ocaml-options-vanilla.1
⬇ retrieved conf-gmp.4  (https://opam.ocaml.org/cache)
∗ installed conf-gmp.4
⬇ retrieved base64.3.5.1  (https://opam.ocaml.org/cache)
∗ installed conf-pkg-config.4
∗ installed conf-zlib.1
⬇ retrieved conf-gmp-powm-sec.3  (https://opam.ocaml.org/cache)
∗ installed conf-gmp-powm-sec.3
⬇ retrieved conf-zmq.0.1  (https://opam.ocaml.org/cache)
∗ installed conf-zmq.0.1
⬇ retrieved base.v0.15.1  (https://opam.ocaml.org/cache)
⬇ retrieved cppo.1.8.0  (https://opam.ocaml.org/cache)
⬇ retrieved csexp.1.5.2  (https://opam.ocaml.org/cache)
⬇ retrieved cryptokit.1.20  (https://opam.ocaml.org/cache)
⬇ retrieved logs.0.7.0  (https://opam.ocaml.org/cache)
⬇ retrieved jupyter.2.8.3  (https://opam.ocaml.org/cache)
⬇ retrieved ocaml-compiler-libs.v0.12.4  (https://opam.ocaml.org/cache)
⬇ retrieved dune.3.17.2, dune-configurator.3.17.2  (https://opam.ocaml.org/cache)
⊘ removed   base-effects.base
⊘ removed   base-nnp.base
⊘ removed   base-domains.base
⊘ removed   ocaml.5.3.0
⊘ removed   ocaml-config.3
⊘ removed   ocaml-base-compiler.5.3.0
⊘ removed   ocaml-compiler.5.3.0
∗ installed ocaml-option-nnp.1
⬇ retrieved ocaml-config.2  (2 extra sources)
⬇ retrieved ocaml-config.2  (2 extra sources)
⬇ retrieved lwt.5.9.1, lwt_ppx.5.9.1  (https://opam.ocaml.org/cache)
⬇ retrieved ocamlbuild.0.16.1  (https://opam.ocaml.org/cache)
⬇ retrieved ocamlfind.1.9.8  (https://opam.ocaml.org/cache)
⬇ retrieved ocplib-endian.1.2  (https://opam.ocaml.org/cache)
⬇ retrieved octavius.1.2.2  (https://opam.ocaml.org/cache)
⬇ retrieved ppx_derivers.1.2.1  (https://opam.ocaml.org/cache)
⬇ retrieved ppx_deriving.6.0.3  (https://opam.ocaml.org/cache)
⬇ retrieved ppx_js_style.v0.15.0  (https://opam.ocaml.org/cache)
⬇ retrieved ppx_yojson_conv_lib.v0.15.0  (https://opam.ocaml.org/cache)
⬇ retrieved ppx_yojson_conv.v0.15.1  (https://opam.ocaml.org/cache)
⬇ retrieved seq.base  (2 extra sources)
⬇ retrieved seq.base  (2 extra sources)
⬇ retrieved ppxlib.0.35.0  (https://opam.ocaml.org/cache)
⬇ retrieved sexplib0.v0.15.1  (https://opam.ocaml.org/cache)
⬇ retrieved stdint.0.7.2  (https://opam.ocaml.org/cache)
⬇ retrieved stdlib-shims.0.3.0  (https://opam.ocaml.org/cache)
⬇ retrieved uuidm.0.9.8  (https://opam.ocaml.org/cache)
⬇ retrieved topkg.1.0.8  (https://opam.ocaml.org/cache)
⬇ retrieved yojson.2.2.2  (https://opam.ocaml.org/cache)
⬇ retrieved zarith.1.14  (https://opam.ocaml.org/cache)
⬇ retrieved zmq.5.3.0, zmq-lwt.5.3.0  (https://opam.ocaml.org/cache)
⬇ retrieved ocaml-variants.4.12.0+domains+effects  (git+https://github.com/ocaml-multicore/ocaml-multicore.git#4.12+domains+effects)
[ERROR] The compilation of ocaml-variants.4.12.0+domains+effects failed at
        "make -j1".

#=== ERROR while compiling ocaml-variants.4.12.0+domains+effects =============#
# context              2.3.0 | linux/arm64 |  | https://opam.ocaml.org#a8ed476033bb6d4d29d63b5907404e6ef35a302d
# path                 ~/.opam/default/.opam-switch/build/ocaml-variants.4.12.0+domains+effects
# command              /usr/bin/make -j1
# exit-code            2
# env-file             ~/.opam/log/ocaml-variants-249839-e66665.env
# output-file          ~/.opam/log/ocaml-variants-249839-e66665.out
### output ###
# [...]
# fiber.c: In function ‘caml_maybe_expand_stack’:
# fiber.c:235:53: error: ‘Wosize_gc_regs’ undeclared (first use in this function)
#   235 |     value* bucket = caml_stat_alloc(sizeof(value) * Wosize_gc_regs);
#       |                                                     ^~~~~~~~~~~~~~
# fiber.c:235:53: note: each undeclared identifier is reported only once for each function it appears in
# make[3]: *** [Makefile:378: fiber.n.o] Error 1
# make[3]: Leaving directory '/home/u25997/.opam/default/.opam-switch/build/ocaml-variants.4.12.0+domains+effects/runtime'
# make[2]: *** [Makefile:766: makeruntimeopt] Error 2
# make[2]: Leaving directory '/home/u25997/.opam/default/.opam-switch/build/ocaml-variants.4.12.0+domains+effects'
# make[1]: *** [Makefile:216: opt.opt] Error 2
# make[1]: Leaving directory '/home/u25997/.opam/default/.opam-switch/build/ocaml-variants.4.12.0+domains+effects'
# make: *** [Makefile:276: world.opt] Error 2



<><> Error report ><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml-variants 4.12.0+domains+effects
└─ 
┌─ The following changes have been performed (the rest was aborted)
│ ⊘ remove  base-domains          base
│ ⊘ remove  base-effects          base
│ ⊘ remove  base-nnp              base
│ ⊘ remove  ocaml                 5.3.0
│ ⊘ remove  ocaml-base-compiler   5.3.0
│ ⊘ remove  ocaml-compiler        5.3.0
│ ⊘ remove  ocaml-config          3
│ ⊘ remove  ocaml-options-vanilla 1
│ ∗ install conf-gmp              4
│ ∗ install conf-gmp-powm-sec     3
│ ∗ install conf-pkg-config       4
│ ∗ install conf-zlib             1
│ ∗ install conf-zmq              0.1
│ ∗ install ocaml-option-nnp      1
└─ 
# To update the current shell environment, run: eval $(opam env)

The former state can be restored with:
    /usr/local/bin/opam switch import
"/home/u25997/.opam/default/.opam-switch/backup/state-20250317074243.export"
Or you can retry to install your package selection with:
    /usr/local/bin/opam install --restore
u25997@taulecgw:~$ 

You shouldn’t be using this switch anymore. It was used solely for development and isn’t maintained anymore. If you want domain and effects, you should be using the shiny OCaml 5.3! and if you don’t, you should still be using OCaml 5.3!