Building for MacOS x86 and arm64 with setup-ocaml

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