Owning solely a GNU/Linux machine, I currently build an executable for Linux x86-64, Windows and MacOS x86 using the setup-ocaml GH CI facility (many thanks to its authors). (To be able to build on all 3 platforms, I had to fix the version of packages in a way that works on all of them, which was a bit tedious and took some time, btw).
Users of my program who own a Mac M1/M2/M3 apparently can’t run the program. Is there a way to add MacOS arm64 as a 4th target?
1 Like
If you use macos-14
you will pickup an ARM64/M1 worker. Confusingly macos-latest
is x86_64
2 Likes
Thanks it works !
Tiebreaker question: it seems like there also exists a possibility of “universal” binary for MacOS. Provided it’s the case, is there a way to build one with a MacOS target in setup-ocaml?
Not easily, it would require OCaml cross compilation to emit the x86/arm64 OCaml assembly.
1 Like
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-13
label). Upload an artifact of the executable
- Build on a Apple Silicon mac (gh actions
macos-14
or macos-latest
). Upload an artifact of this executable
- 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