I am trying to install an old ocaml version on my macos.
`opam switch create compcert-tso ocaml-base-compiler.3.12.0`
But I got the following errors, could you please give me some suggestions?
#=== ERROR while compiling ocaml-base-compiler.3.12.0 =========================#
# context 2.0.7 | macos/x86_64 | | https://opam.ocaml.org#3a6c6fae
# path ~/.opam/compcert-tso/.opam-switch/build/ocaml-base-compiler.3.12.0
# command ~/.opam/opam-init/hooks/sandbox.sh build make world
# exit-code 2
# env-file ~/.opam/log/ocaml-base-compiler-56675-a00279.env
# output-file ~/.opam/log/ocaml-base-compiler-56675-a00279.out
### output ###
# [...]
# lseek.c:58:3: error: implicit declaration of function 'caml_enter_blocking_section' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
# caml_enter_blocking_section();
# ^
# lseek.c:60:3: error: implicit declaration of function 'caml_leave_blocking_section' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
# caml_leave_blocking_section();
# ^
# 4 errors generated.
# make[2]: *** [../Makefile.shared:90: lseek.o] Error 1
# make[2]: Leaving directory '/Users/syuan/.opam/compcert-tso/.opam-switch/build/ocaml-base-compiler.3.12.0/otherlibs/unix'
# make[1]: *** [Makefile:656: otherlibraries] Error 2
# make[1]: Leaving directory '/Users/syuan/.opam/compcert-tso/.opam-switch/build/ocaml-base-compiler.3.12.0'
# make: *** [Makefile:138: world] Error 2
I’ve never built software on MacOS, but I’d suggest the following:
try to build this same backlevel ocaml on Linux, with the same version of gcc as you’re using on this mac. Why? b/c that’s the most-used platform, so if the problem still exists there, you can get others to look at it.
if it fails, try with backlevel gcc and with whatever the most-modern GCC is. The latter will allow you to produce a reproducible testcase.
If it works, then get to work on debugging on the Mac: it looks like either a C compiler incompatibility, or include-file weirdness.
Can you share the output of “gcc --version” for your Mac ? I have a Mac, so I could try to build, if I have the same level of GCC (can’t change the level, as it’s a work machine)
FYI, I was able to (partially) build ocaml 3.12.1 using:
gcc --version
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: x86_64-apple-darwin21.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
It failed while building unix, with a missing inet_addr_of_string – since this is further-along than you got, I figured no point in going further until/unless you got this far also. My suspicion (without digging deeper) is include-file hinkiness.
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build ocaml-base-compiler 3.12.0
+-
+- The following changes have been performed (the rest was aborted)
| - install base-bigarray base
| - install base-threads base
| - install base-unix base
+-