When I try to install a new switch in OPAM, I get an error when compiling on a Raspberry Pi and also on recent Ubuntu (20.10 and 20.04 LTS). I have search for other with same problem, but have not found any solution that works.
anders@anders-pi:~ $ sudo apt install opam
[sudo] password for user anders:
Läser paketlistor… Färdig
Bygger beroendeträd
Läser tillståndsinformation… Färdig
The following additional packages will be installed:
coinor-cbc darcs ledit libncurses-dev libncurses5-dev mccs ocaml ocaml-base
ocaml-base-nox ocaml-compiler-libs ocaml-interp ocaml-nox opam-doc
opam-installer
Suggested packages:
ncurses-doc ocaml-doc tuareg-mode | ocaml-mode
These NEW packages will be installed:
coinor-cbc darcs ledit libncurses-dev libncurses5-dev mccs ocaml ocaml-base
ocaml-base-nox ocaml-compiler-libs ocaml-interp ocaml-nox opam opam-doc
opam-installer
0 upgraded, 15 new, 0 removed 0 not upgraded.
Behöver hämta 56,6 MB arkiv.
Efter denna åtgärd kommer ytterligare 246 MB utrymme användas på disken.
Do you want to continue? [Y/n]
Read:1 http://raspbian.playstar.se/raspbian buster/main armhf darcs armhf 2.14.1-3 [4 851 kB]
Read:5 http://raspbian.raspberrypi.org/raspbian buster/main armhf libncurses5-dev armhf 6.1+20181013-2+deb10u2 [948 B]
Läs:2 http://raspbian.playstar.se/raspbian buster/main armhf ocaml-base-nox armhf 4.05.0-11+rpi1 [577 kB]
Läs:3 http://raspbian.playstar.se/raspbian buster/main armhf ledit all 2.04-1 [49,1 kB]
Läs:4 http://raspbian.playstar.se/raspbian buster/main armhf libncurses-dev armhf 6.1+20181013-2+deb10u2 [278 kB]
Läs:6 http://raspbian.playstar.se/raspbian buster/main armhf coinor-cbc armhf 2.9.9+repack1-1 [13,4 kB]
Läs:7 http://raspbian.playstar.se/raspbian buster/main armhf mccs armhf 1:1.1-8 [242 kB]
Läs:8 http://raspbian.playstar.se/raspbian buster/main armhf ocaml-base armhf 4.05.0-11+rpi1 [157 kB]
Läs:9 http://raspbian.playstar.se/raspbian buster/main armhf ocaml-compiler-libs armhf 4.05.0-11+rpi1 [19,2 MB]
Läs:10 http://raspbian.playstar.se/raspbian buster/main armhf ocaml-interp armhf 4.05.0-11+rpi1 [3 582 kB]
Läs:11 http://raspbian.playstar.se/raspbian buster/main armhf ocaml-nox armhf 4.05.0-11+rpi1 [25,1 MB]
Läs:12 http://raspbian.playstar.se/raspbian buster/main armhf ocaml armhf 4.05.0-11+rpi1 [162 kB]
Läs:13 http://raspbian.playstar.se/raspbian buster/main armhf opam-installer armhf 2.0.3-1+deb10u1 [751 kB]
Läs:14 http://raspbian.playstar.se/raspbian buster/main armhf opam-doc all 2.0.3-1+deb10u1 [219 kB]
Läs:15 http://raspbian.playstar.se/raspbian buster/main armhf opam armhf 2.0.3-1+deb10u1 [1 405 kB]
Hämtade 56,6 MB på 9s (6 379 kB/s)
Väljer tidigare ej valt paket darcs.
(Läser databasen ... 367847 filer och kataloger installerade.)
Förbereder att packa upp .../00-darcs_2.14.1-3_armhf.deb ...
Packar upp darcs (2.14.1-3) ...
Väljer tidigare ej valt paket ocaml-base-nox.
Förbereder att packa upp .../01-ocaml-base-nox_4.05.0-11+rpi1_armhf.deb ...
Packar upp ocaml-base-nox (4.05.0-11+rpi1) ...
Väljer tidigare ej valt paket ledit.
Förbereder att packa upp .../02-ledit_2.04-1_all.deb ...
Packar upp ledit (2.04-1) ...
Väljer tidigare ej valt paket libncurses-dev:armhf.
Förbereder att packa upp .../03-libncurses-dev_6.1+20181013-2+deb10u2_armhf.deb ...
Packar upp libncurses-dev:armhf (6.1+20181013-2+deb10u2) ...
Väljer tidigare ej valt paket libncurses5-dev:armhf.
Förbereder att packa upp .../04-libncurses5-dev_6.1+20181013-2+deb10u2_armhf.deb ...
Packar upp libncurses5-dev:armhf (6.1+20181013-2+deb10u2) ...
Väljer tidigare ej valt paket coinor-cbc.
Förbereder att packa upp .../05-coinor-cbc_2.9.9+repack1-1_armhf.deb ...
Packar upp coinor-cbc (2.9.9+repack1-1) ...
Väljer tidigare ej valt paket mccs.
Förbereder att packa upp .../06-mccs_1%3a1.1-8_armhf.deb ...
Packar upp mccs (1:1.1-8) ...
Väljer tidigare ej valt paket ocaml-base.
Förbereder att packa upp .../07-ocaml-base_4.05.0-11+rpi1_armhf.deb ...
Packar upp ocaml-base (4.05.0-11+rpi1) ...
Väljer tidigare ej valt paket ocaml-compiler-libs.
Förbereder att packa upp .../08-ocaml-compiler-libs_4.05.0-11+rpi1_armhf.deb ...
Packar upp ocaml-compiler-libs (4.05.0-11+rpi1) ...
Väljer tidigare ej valt paket ocaml-interp.
Förbereder att packa upp .../09-ocaml-interp_4.05.0-11+rpi1_armhf.deb ...
Packar upp ocaml-interp (4.05.0-11+rpi1) ...
Väljer tidigare ej valt paket ocaml-nox.
Förbereder att packa upp .../10-ocaml-nox_4.05.0-11+rpi1_armhf.deb ...
Packar upp ocaml-nox (4.05.0-11+rpi1) ...
Väljer tidigare ej valt paket ocaml.
Förbereder att packa upp .../11-ocaml_4.05.0-11+rpi1_armhf.deb ...
Packar upp ocaml (4.05.0-11+rpi1) ...
Väljer tidigare ej valt paket opam-installer.
Förbereder att packa upp .../12-opam-installer_2.0.3-1+deb10u1_armhf.deb ...
Packar upp opam-installer (2.0.3-1+deb10u1) ...
Väljer tidigare ej valt paket opam-doc.
Förbereder att packa upp .../13-opam-doc_2.0.3-1+deb10u1_all.deb ...
Packar upp opam-doc (2.0.3-1+deb10u1) ...
Väljer tidigare ej valt paket opam.
Förbereder att packa upp .../14-opam_2.0.3-1+deb10u1_armhf.deb ...
Packar upp opam (2.0.3-1+deb10u1) ...
Ställer in libncurses-dev:armhf (6.1+20181013-2+deb10u2) ...
Ställer in opam-doc (2.0.3-1+deb10u1) ...
Ställer in darcs (2.14.1-3) ...
Ställer in coinor-cbc (2.9.9+repack1-1) ...
Ställer in opam-installer (2.0.3-1+deb10u1) ...
Ställer in libncurses5-dev:armhf (6.1+20181013-2+deb10u2) ...
Ställer in ocaml-base-nox (4.05.0-11+rpi1) ...
Ställer in ledit (2.04-1) ...
update-alternatives: använder /usr/bin/ledit för att tillhandahålla /usr/bin/readline-editor (readline-editor) i autoläge
Ställer in mccs (1:1.1-8) ...
Ställer in ocaml-base (4.05.0-11+rpi1) ...
Ställer in opam (2.0.3-1+deb10u1) ...
Ställer in ocaml-compiler-libs (4.05.0-11+rpi1) ...
Ställer in ocaml-interp (4.05.0-11+rpi1) ...
Ställer in ocaml-nox (4.05.0-11+rpi1) ...
Ställer in ocaml (4.05.0-11+rpi1) ...
Hanterar utlösare för man-db (2.8.5-2) ...
Hanterar utlösare för desktop-file-utils (0.23-4) ...
Hanterar utlösare för mime-support (3.62) ...
Hanterar utlösare för gnome-menus (3.31.4-3) ...
anders@anders-pi:~ $ opam init
[NOTE] Will configure from built-in defaults.
Checking for available remotes: rsync and local, git, mercurial, darcs. Perfect!
<><> 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 ~/.profile:
test -r /home/anders/.opam/opam-init/init.sh && . /home/anders/.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.
Do you want opam to modify ~/.profile? [N/y/f]
(default is 'no', use 'f' to choose a different file) y
A hook can be added to opam's init scripts to ensure that the shell remains in
sync with the opam environment when they are loaded. Set that up? [y/N] y
User configuration:
Updating ~/.profile.
[NOTE] Make sure that ~/.profile is well sourced in your ~/.bashrc.
<><> Creating initial switch (ocaml-system>=4.02.3) <><><><><><><><><><><><><><>
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
∗ installed ocaml-system.4.05.0
∗ installed ocaml-config.1
∗ installed ocaml.4.05.0
Done.
# Run eval $(opam env) to update the current shell environment
anders@anders-pi:~ $ eval $(opam env)
anders@anders-pi:~ $ opam switch create 4.11.1
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ocaml-base-compiler.4.11.1] downloaded from cache at https://opam.ocaml.org/cache
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
[ERROR] The compilation of ocaml-base-compiler failed at
"/home/anders/.opam/opam-init/hooks/sandbox.sh build make -j3 world".
#=== ERROR while compiling ocaml-base-compiler.4.11.1 =========================#
# context 2.0.3 | linux/arm32 | | https://opam.ocaml.org#7fded676
# path ~/.opam/4.11.1/.opam-switch/build/ocaml-base-compiler.4.11.1
# command ~/.opam/opam-init/hooks/sandbox.sh build make -j3 world
# exit-code 2
# env-file ~/.opam/log/ocaml-base-compiler-8595-60459a.env
# output-file ~/.opam/log/ocaml-base-compiler-8595-60459a.out
### output ###
# [...]
# File "_none_", line 1:
# Error: Error while linking ../../stdlib/stdlib.cma(Stdlib):
# Reference to undefined global `Stack_overflow'
# make[4]: *** [Makefile:233: extract_crc] Fel 2
# make[4]: Lämnar katalogen ”/home/anders/.opam/4.11.1/.opam-switch/build/ocaml-base-compiler.4.11.1/otherlibs/dynlink”
# make[3]: *** [Makefile:35: all] Fel 2
# make[3]: Lämnar katalogen ”/home/anders/.opam/4.11.1/.opam-switch/build/ocaml-base-compiler.4.11.1/otherlibs”
# make[2]: *** [Makefile:903: otherlibraries] Fel 2
# make[2]: Lämnar katalogen ”/home/anders/.opam/4.11.1/.opam-switch/build/ocaml-base-compiler.4.11.1”
# make[1]: *** [Makefile:260: all] Fel 2
# make[1]: Lämnar katalogen ”/home/anders/.opam/4.11.1/.opam-switch/build/ocaml-base-compiler.4.11.1”
# make: *** [Makefile:277: world] Fel 2
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml-base-compiler 4.11.1
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray base
│ ∗ install base-threads base
│ ∗ install base-unix base
└─
<><> ocaml-base-compiler.4.11.1 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/ocaml/issues
# Run eval $(opam env) to update the current shell environment
Switch initialisation failed: clean up? ('n' will leave the switch partially
installed) [Y/n] y
anders@anders-pi:~ $ gcc --version
gcc (Raspbian 8.3.0-6+rpi1) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
anders@anders-pi:~ $ opam --version
2.0.3
anders@anders-pi:~ $ ocaml --version
The OCaml toplevel, version 4.05.0
anders@anders-pi:~ $ opam switch list
# switch compiler description
→ default ocaml-system.4.05.0 default
anders@anders-pi:~ $ uname -a
Linux anders-pi 5.10.11-v7l+ #1399 SMP Thu Jan 28 12:09:48 GMT 2021 armv7l GNU/Linux
anders@anders-pi:~ $
So, what am I doing wrong?
Ok, this is what I do when I compile from the git source.
bda -I middle_end/flambda/base_types -I asmcomp -I asmcomp/debug -I driver -I toplevel -c driver/maindriver.ml -I driver
./boot/ocamlrun ./ocamlopt -g -nostdlib -I stdlib -I otherlibs/dynlink -a -ccopt "-Wl,-E" -o compilerlibs/ocamlbytecomp.cmxa bytecomp/instruct.cmx bytecomp/bytegen.cmx bytecomp/printinstr.cmx bytecomp/emitcode.cmx bytecomp/bytelink.cmx bytecomp/bytelibrarian.cmx bytecomp/bytepackager.cmx driver/errors.cmx driver/compile.cmx driver/maindriver.cmx
./boot/ocamlrun ./ocamlopt -g -nostdlib -I stdlib -I otherlibs/dynlink -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66 -warn-error +a -bin-annot -safe-string -strict-formats -I utils -I parsing -I typing -I bytecomp -I file_formats -I lambda -I middle_end -I middle_end/closure -I middle_end/flambda -I middle_end/flambda/base_types -I asmcomp -I asmcomp/debug -I driver -I toplevel -c driver/main.ml -I driver
./boot/ocamlrun ./ocamlopt -g -nostdlib -I stdlib -I otherlibs/dynlink -o ocamlc.opt compilerlibs/ocamlcommon.cmxa compilerlibs/ocamlbytecomp.cmxa driver/main.cmx -cclib "-lm -ldl -lpthread"
/usr/bin/ld: stdlib/stdlib.a(stdlib.o): in function `.L620':
/home/anders/Src/GitHub/ocaml/stdlib/stdlib.ml:571: undefined reference to `caml_exn_Stack_overflow'
/usr/bin/ld: stdlib/libasmrun.a(fail_nat.n.o): in function `caml_raise_constant':
/home/anders/Src/GitHub/ocaml/runtime/fail_nat.c:88: undefined reference to `caml_exn_Stack_overflow'
collect2: error: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking (exit code 1)
make[2]: *** [Makefile:664: ocamlc.opt] Fel 2
make[2]: Lämnar katalogen ”/home/anders/Src/GitHub/ocaml”
make[1]: *** [Makefile:218: opt.opt] Fel 2
make[1]: Lämnar katalogen ”/home/anders/Src/GitHub/ocaml”
make: *** [Makefile:277: world.opt] Fel 2
anders@anders-pi:~/Src/GitHub/ocaml $
Are there something obvious, or should I file a bug report?