ARM64 macOS binaries
bcr opened this issue · comments
I have an M1 Mac with no Rosetta and @jroweboy pointed out that the Mac binaries are x86_64 right now.
I presume there's two options:
- Separate builds for x86_64 and arm64
- Fat binaries with both
I presume there's some risk that building for arm64 opens a can of worms (doesn't work for some reason.)
➜ llvm-mos bin/clang --version
zsh: bad CPU type in executable: bin/clang
➜ llvm-mos file bin/clang
bin/clang: Mach-O 64-bit executable x86_64
➜ llvm-mos uname -a
Darwin blakes-mbp.lan 21.6.0 Darwin Kernel Version 21.6.0: Thu Jul 6 22:20:00 PDT 2023; root:xnu-8020.240.18.702.13~1/RELEASE_ARM64_T6000 arm64
I'm digging into it some more. I think the core is that macos-latest
is 12.6.9 on Intel, so the compiler builds x86_64 single architecture.
I found this link that might be useful about building fat binaries (strategy 1 above), still reading. https://discourse.llvm.org/t/build-runtimes-for-the-same-archs-as-llvm/71522
I was under the impression that M1's could emulate x86_64 for backwards compatibility. In general on the great majority of projects, compilation time for llvm-mos is negligible.
I also note that GitHub recently added M1 runners, so it should technically be possible to run llvm-mos automated tests on that target.
I was under the impression that M1's could emulate x86_64 for backwards compatibility.
I think the way that Apple has chosen to do this is the same as the migration from the IBM ARM processors to the Intel processors -- they have a translation service called Rosetta that handles running code for the non-native platform. For the original Rosetta, they supported it for I think five years and then stopped. For the current Rosetta we are four years into the transition, so there's a real potential for support to end in the next year or so.
As far as I can tell this is fixed with llvm-mos/llvm-mos#274 -- I was able to download the latest artifact.zip and compile and run the k_console_test
in the x16 emulator.
Whoops, some local binaries are made in this project also. Reopening, but I've got a PR ready.
Looks good based on the prerelease archive.
➜ ~ file ~/llvm-mos/bin/mos-sim
/Users/blake/llvm-mos/bin/mos-sim: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64Mach-O 64-bit executable arm64]
/Users/blake/llvm-mos/bin/mos-sim (for architecture x86_64): Mach-O 64-bit executable x86_64
/Users/blake/llvm-mos/bin/mos-sim (for architecture arm64): Mach-O 64-bit executable arm64