I don’t think it would be very hard: there is an open PR https://github.com/ocaml/ocaml/pull/9699 at the moment adding support for the ARM architectures used in (some?) iPhones, and it is not a very large patch.
The hardest bit of this will getting this in CI, since Apple is charging $500 for a (returnable) loan of their preview kit. I’m going to cough up the cash for this, but it’s pretty developer hostile. If anyone at the Apple open source program office is listening - send us some kit that doesn’t need to be returned, so it can be racked up for test purposes!
@nojb all Apple products uses almost the same architecture nowadays, ARM64(v8), ARM32 is not supported anymore, so this patch gets all iPhone’s since the iPhone 5s. There is also ARMv8.3 called arm64e, which is a must for some low level things(like drivers? and system plugins?).
Besides of that is the same kernel. In a different mode, if you look at the XNU source you’re going to see a lot of flags checking to see if it is a SECURE_KERNEL(like iOS) or not(like a mac)
As pointed by @avsm the main problem is getting the CI to work, I will get my hands on one somehow, maybe not literally but an SSH. But ideally INRIA would have it running
Weird ways to test it
Another alternative is an iPhone X tethered, as it supports jailbreak in every version(it’s a ROM level bypass), about $450 US dollars used. But I’m almost sure that there is some under NDA Apple thing for compilers and tools like that(like an iPhone prototype with JTAG enabled) and tools to hook that properly. So if anyone knows someone who knows someone, that would solve the problem.
Another alternative, I have iOS 12 running on xnu-qemu-arm64, on Linux I made some patches to support async networking, and I’m also working on a KVM patch to that to run on the Raspberry PI. I “made” the patch at #9699 originally in the emulator. That is probably not legal, but really simple to maintain and it’s ready today, jailbreak is actually OK in most countries if you don’t break any DMCA.
I would like to have both macOS ARM and iOS ARM, especially because there is some code which is valid at only iOS, but this second one isn’t so simple to maintain.
Epecifically, there is one test failing which can imply that COQ is still not running, something related to unboxed primitives.
10 days? The OCaml ARM64 code generator is in very good shape already, and the recent pull request https://github.com/ocaml/ocaml/pull/9699 adds iOS ARM64 support, which should not be very far from macOS ARM64 support.
However, I would really like to have SSH access to one of those MacMini ARM64 development platforms. That would speed up porting and testing tremendously. Emulators and jailbreaked phones are a pain.
@bluddy not hard, Android needs some patches after Android 5.0, I have it setup for ARM64 and x86_64 at my personal project, also got iOS x86_64 and ARM64.
I have a tooling to cross compile almost anything with esy, similar to ocaml-cross but more versatile and works with essentially any dune package not using cstubs(you need a patch for that). It was working with OCaml 4.08
The patches itself, not great yet, but will open a PR in the future. Also I want to get x86 PIC to work(Android requires that), which is a lot harder than iOS and Android ARM.
The emulator after you get to work is actually nice, works exactly like any VM, SSH and all, if you guys are okay with that I can setup the CI using it.
But also, maybe trying to give Corellium a try? I’m not a huge fan o Go but if they’re using as a CI it’s probably reliable.
Technically even the ABI of the mac ARM is the same as iOS so I would bet 99% is similar, probably same linker, same kernel. But would be great to have the real thing running as there is a lot of small limitations(like stack_size)
OCaml 4.12 will have full native code macOS/ARM support. The first alpha is due out any day now, and the ecosystem tools will be ready on the day of its release as well, thanks to the OCaml readiness team’s efforts
@EduardoRFS that’s very useful indeed! If you’re able to open a PR against ocaml/ocaml's branch 4.10 with just the code generator backport (and not the iOS-related changes), that would be useful for Homebrew’s macOS OCaml for a month or so until we get 4.12.0 out of the door.