Building for MacOS x86 and arm64 with setup-ocaml

This thread seems to be at the top of search results for “ocaml universal binary”, so forgive the late bump.

I was recently looking into this question. It turns out this is relatively easy using the lipo tool Apple provides and something like github actions where you have access to multiple machines:

  1. Build on an Intel Mac (github actions still has these under the macos-13 label). Upload an artifact of the executable
  2. Build on a Apple Silicon mac (gh actions macos-14 or macos-latest). Upload an artifact of this executable
  3. Now, on an Apple Silcon instance, download those artifacts and then run the lipo tool to combine the two. You now have a universal/fat binary, without ever needing to run a cross compiler
2 Likes