How to build arm64e apps on macOS / iOS

Hey Rustacean!

I'd like to build arm64e apps on macOS. So, I have tried to patch the Rust compiler, but I got the linked error for std, panic_unwind, etc.:

building for iOS-arm64e but attempting to link with file build for unknown-arm64

I have tried to add two new targets: arm64e-apple-ios and arm64e-apple-dawrin. They are based on:

Could you please share your tips how to add support arm64e for iOS/macOS ?

P.S. Support for ARMv8.3+ targets · Issue #73628 · rust-lang/rust · GitHub

My understanding is that this requires using Apple's LLVM fork and modifications to the LLVM IR generator (in this case rustc) to specify the metadata that is checked during pointer authentication. Also do you still have to disable SIP and pass a special kernel arg for macOS to accept arm64e binaries that are not signed by Apple? Also you will need to extend the object crate to support producing arm64e Mach-O object files and change to produce arm64e binaries when using a target that uses them.

Yeah, could you explain why you'd like to do this? It's certainly possible, it's just going to be a lot of work and there might be an easier way to achieve it.

We can build arm64e apps using only C++. However, we have to be able to create arm64e apps for some research using Rust. Therefore, it would be great if Rust compiler supports arm64e architecture.

Hey @bjorn3,

It seems 16 LLVM has the PAuth and arm64e features.

Right now, I am not sure about SIP. We can sign a binary file using the codesign tool.

@arttet If you're only using the app on your local systems (building it yourself) is there a need to code sign it? Is ad hoc code signing not sufficient?

Hey @hansgeunsmeyer,

We usually use cross-compile and check on different systems. For this reason, we need to sign apps manually.

Hey @bjorn3,

Thank you for your great advice. It really works.

Could you please tell me what the best way is to add pauth for Rust?

It seems we need to add the following intrinsics (Pointer Authentication — LLVM 18.0.0git documentation):



Yeah, you will need to add those intrinsics there. And then you will need to add the intrinsic calls in the appropriate locations. I'm not sure what the appropriate locations would be though. I did recommend taking a look at where clang calls them.

Hey @bjorn3,

How are you?

I have prepared a PR. Could you please look at it and let me know your opinion about it?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.