As a user of Coq on Macs, I wonder if OCaml will add native support for their new ARM CPUs, and how hard it is, and how long would that take roughly — 1month, 1 year, 10 years?
I realize this question might be very hard and annoying to answer, but I see OCaml has already ports for ARM-Linux and Mac-x86, which gives me hope?
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)
#If SECURE_KERNEL
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.
COQ
Epecifically, there is one test failing which can imply that COQ is still not running, something related to unboxed primitives.
I think it’s possible to use Corellium iPhone emulation for development. Many projects and researchers rely on it. For example, Go language uses it for CI.
Another alternative is to run iOS in QEMU as it had been told already:
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)
That’s amazing, I had started to look on that, but not a lot of spare time, will try to see if it can runs the macOS ARM, as the kernel is really similar
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.
I don’t have a lot of spare time right know, but I opened the PR, left the iOS changes as they’re quite small and I don’t have a macOS ARM box to test right know.
But backporting to 4.11 is easier, as there is no conflict, if you want to try is the same 3 commits on this PR