Installing base on Apple Silicon using opam

Hi all,

I’m trying to install VsCoq so I could use the Coq system with VsCode, and it requires basic 0.16.3. However, I get the following error:

[ERROR] The compilation of base.v0.16.3 failed at "dune build -p base -j 7".

#=== ERROR while compiling base.v0.16.3 =======================================#
# context     2.3.0 | macos/arm64 | ocaml-base-compiler.4.14.2 | https://opam.ocaml.org#4d8fa0fb8fce3b6c8b06f29ebcfa844c292d4f3e
# path        ~/.opam/4.14.2/.opam-switch/build/base.v0.16.3
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p base -j 7
# exit-code   1
# env-file    ~/.opam/log/base-47384-f1f924.env
# output-file ~/.opam/log/base-47384-f1f924.out
### output ###
# [...]
# (cd _build/default/src && /usr/bin/cc -O2 -fno-strict-aliasing -fwrapv -pthread -D_FILE_OFFSET_BITS=64 -O2 -fno-strict-aliasing -fwrapv -pthread -D_LARGEFILE64_SOURCE -mpopcnt -g -I /Users/aadit/.opam/4.14.2/lib/ocaml -I /Users/aadit/.opam/4.14.2/lib/sexplib0 -I ../compiler-stdlib/src -I ../hash_types/src -I ../shadow-stdlib/src -o exn_stubs.o -c exn_stubs.c)
# clang: error: unsupported option '-mpopcnt' for target 'arm64-apple-darwin24.5.0'
# File "src/dune", line 14, characters 47-57:
# 14 |  (c_names bytes_stubs exn_stubs int_math_stubs hash_stubs am_testing)
#                                                     ^^^^^^^^^^
# (cd _build/default/src && /usr/bin/cc -O2 -fno-strict-aliasing -fwrapv -pthread -D_FILE_OFFSET_BITS=64 -O2 -fno-strict-aliasing -fwrapv -pthread -D_LARGEFILE64_SOURCE -mpopcnt -g -I /Users/aadit/.opam/4.14.2/lib/ocaml -I /Users/aadit/.opam/4.14.2/lib/sexplib0 -I ../compiler-stdlib/src -I ../hash_types/src -I ../shadow-stdlib/src -o hash_stubs.o -c hash_stubs.c)
# clang: error: unsupported option '-mpopcnt' for target 'arm64-apple-darwin24.5.0'
# File "src/dune", line 14, characters 58-68:
# 14 |  (c_names bytes_stubs exn_stubs int_math_stubs hash_stubs am_testing)
#                                                                ^^^^^^^^^^
# (cd _build/default/src && /usr/bin/cc -O2 -fno-strict-aliasing -fwrapv -pthread -D_FILE_OFFSET_BITS=64 -O2 -fno-strict-aliasing -fwrapv -pthread -D_LARGEFILE64_SOURCE -mpopcnt -g -I /Users/aadit/.opam/4.14.2/lib/ocaml -I /Users/aadit/.opam/4.14.2/lib/sexplib0 -I ../compiler-stdlib/src -I ../hash_types/src -I ../shadow-stdlib/src -o am_testing.o -c am_testing.c)
# clang: error: unsupported option '-mpopcnt' for target 'arm64-apple-darwin24.5.0'



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
┌─ The following actions failed
│ λ build base v0.16.3

Is base compatible with Apple Silicon? Thanks for any help!

1 Like

Upstream base is not compatible with the latest Xcode at the moment.
Only v0.17.1 has been patched in opam-repository if i’m following the upstream ticket correctly: janestreet/base#178

EDIT: nevermind, a patched version for v0.16 was released as v0.16.4 (ocaml/opam-repository#27723). So a simple opam update should fix your issue

2 Likes

Ah thank you, this did the trick!