Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building for ARM64e on M1 Apple silicon

I'm building my command line app, and noticed that all the binaries I create are of type arm64.

However, all the bins that ship with macOS 11.4 are arm64e.

i.e. running file on my app built on an M1 MacBook shows:

Mach-O 64-bit executable arm64

Whereas, running file on the system xxd app on the same machine shows:

Mach-O 64-bit executable arm64e

I've looked in Xcode and cannot see how to augment this, should Xcode not be building arm64e? If so how can I achieve the same?

Here's a picture: enter image description here

EDIT: I think the answer might be, the arm64e ABI is unstable and not in use for anyone but Apple?

like image 395
Woodstock Avatar asked Nov 15 '22 21:11

Woodstock


1 Answers

The main difference between targeting arm64 and arm64e is ARMv8.3's Pointer Authentication Codes. Since the specific ABI hasn't stabilized, Apple is only using it for their own platform code since they can easily recompile the entire OS version with a different ABI by shipping a new OS whereas they can't really force all developers to start using a new ABI.

Despite this, you can compile for arm64e simply by choosing "other..." on the architectures drop down and typing in arm64e. By default, macOS will refuse to run any non-Apple code that has the arm64e slice (since they want to prevent anyone from shipping arm64e code before the ABI is stable). You can, however, override this behavior and allow macOS to run non-Apple arm64e code by setting the arm64e_preview_abi bootarg:

sudo nvram boot-args=-arm64e_preview_abi

Note that you will need to disable system integrity protection to do so. This bootarg is meant to allow developers to prepare their software to run with pointer authentication enabled and really not much else.

like image 149
Allison Avatar answered Dec 23 '22 16:12

Allison