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]
# lseek.c:60:3: error: implicit declaration of function 'caml_leave_blocking_section' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
# 4 errors generated.
# make: *** [../Makefile.shared:90: lseek.o] Error 1
# make: Leaving directory '/Users/syuan/.opam/compcert-tso/.opam-switch/build/ocaml-base-compiler.3.12.0/otherlibs/unix'
# make: *** [Makefile:656: otherlibraries] Error 2
# make: 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.
I’d put my $$ on include-file weirdness.
Looks like you are using a C compiler which is too recent and that defaults to C99 mode. The source of 3.12 is not C99-compliant.
Also, note that 3.12 won’t work with arm macs.
Thx, I will test it this evening, and return the feedback~
ok, thx, I will try an old gcc version ~
I tested it on ubuntu1~20.04.1, it works very well. I change to Ubuntu now. So Mac needs an older gcc version(maybe 9.3 or …)
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:
Apple clang version 13.1.6 (clang-13188.8.131.52.5)
Thread model: posix
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.
% gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1184.108.40.206)
Thread model: posix
I could install
base-unix, here is the report:
<><> 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
base-unix doesn’t do much. At this point, you should be going beneath opam and running the
make world commands yourself.