OCaml for ARM MacOS

,

It’s quite easy to get up to speed using the precompiled OPAM binary for macOS/ARM64.

  • Download opam-2.0.7-arm64-macos.

  • Move it to some directory in your PATH, rename it to opam, and make it executable. From a Terminal window:

mv ~/Downloads/opam-2.0.7-arm64-macos /usr/local/bin/opam
chmod +x /usr/local/bin/opam
  • Try to execute it: opam init. You will be blocked by the macOS security checks, as the binary is not signed.

  • Open Preferences / Security and Privacy. There should be a notice “opam was blocked because…” and an “Allow Anyway” button. Click on that button.

  • Try again to execute opam init. You will be blocked again, but now there is an “Open” button. Click on that button. opam init should run and install the OCaml 4.10.2 compiler.

  • From now on, you can run opam without being blocked. Use this freedom to opam install the packages you need.

  • Some packages that depend on external C libraries may fail to install because these C libraries are not available. Normally we would rely on Homebrew or MacPorts to provide these C libraries, but these package collections are still being ported to macOS/ARM64.

As a reward for these minor inconveniences, you’ll get excellent performance running OCaml software such as Coq. Single-core performance on a MacBook Air M1 is 20% better than the best x86 workstation I have access to.

17 Likes