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:
- Build on an Intel Mac (github actions still has these under the
macos-13label). Upload an artifact of the executable - Build on a Apple Silicon mac (gh actions
macos-14ormacos-latest). Upload an artifact of this executable - Now, on an Apple Silcon instance, download those artifacts and then run the
lipotool to combine the two. You now have a universal/fat binary, without ever needing to run a cross compiler