Skip to content

arm64e: set ptrauth ABI subtype on lib.rmeta Mach-O objects#155716

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
cypherair:prep/upstream-ready-arm64e-ptrauth-core-diagnostics-2026-04-24-u9836b06
Apr 27, 2026
Merged

arm64e: set ptrauth ABI subtype on lib.rmeta Mach-O objects#155716
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
cypherair:prep/upstream-ready-arm64e-ptrauth-core-diagnostics-2026-04-24-u9836b06

Conversation

@cypherair
Copy link
Copy Markdown
Contributor

@cypherair cypherair commented Apr 24, 2026

Set CPU_SUBTYPE_PTRAUTH_ABI (as well as the existing CPU_SUBTYPE_ARM64E) on ARM64e object files that rustc creates, to match Clang/LLVM-generated ARM64e objects.

This corresponds to cpusubtype == 0x80000002. Before this change, rustc emitted the bare CPU_SUBTYPE_ARM64E subtype for the metadata wrapper objects / symbols.o file, producing 0x00000002, which can be reported by Apple's linker as arm64e.old.

Fixes rust-lang/rust#130085.
Fixes rust-lang/rust#143844.
Fixes rust-lang/rust#150046.
Fixes rust-lang/rust#139218.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 24, 2026

Some changes occurred in src/doc/unstable-book/src/compiler-flags/branch-protection.md

cc @rust-lang/project-exploit-mitigations, @rcvalle

These commits modify compiler targets.
(See the Target Tier Policy.)

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. O-apple Operating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS) PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 24, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 24, 2026

r? @adwinwhite

rustbot has assigned @adwinwhite.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 19 candidates

@madsmtm
Copy link
Copy Markdown
Contributor

madsmtm commented Apr 24, 2026

r? me

@rustbot rustbot assigned madsmtm and unassigned adwinwhite Apr 24, 2026
@madsmtm
Copy link
Copy Markdown
Contributor

madsmtm commented Apr 24, 2026

My understanding of the ARM64e situation is that it cannot be solved in rustc, it needs LLVM work? Or rather, it needs Apple to upstream their LLVM changes?

@cypherair cypherair changed the title arm64e: add Apple pointer authentication codegen support arm64e: add Apple ptrauth codegen support Apr 24, 2026
@cypherair
Copy link
Copy Markdown
Contributor Author

Thanks for pointing this out. I updated the title and description to make the scope clearer.

This PR doesn’t provide full Apple arm64e support. It covers the rustc-side ptrauth codegen pieces for Rust’s own codegen paths, and full arm64e support still needs LLVM work.

@cypherair cypherair marked this pull request as draft April 25, 2026 18:52
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 25, 2026
@cypherair cypherair changed the title arm64e: add Apple ptrauth codegen support arm64e: prototype rustc-side ptrauth codegen support for Apple targets Apr 25, 2026
@cypherair
Copy link
Copy Markdown
Contributor Author

I’m converting this PR back to draft while I re-check its scope and fix gaps in the current implementation.

@cypherair cypherair changed the title arm64e: prototype rustc-side ptrauth codegen support for Apple targets arm64e: set ptrauth ABI subtype on lib.rmeta Mach-O objects Apr 25, 2026
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-compiler-builtins Area: compiler-builtins (https://github.com/rust-lang/compiler-builtins) A-compiletest Area: The compiletest test runner A-rustc-dev-guide Area: rustc-dev-guide A-testsuite Area: The testsuite used to check the correctness of rustc A-tidy Area: The tidy tool T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 25, 2026
@madsmtm madsmtm added A-codegen Area: Code generation and removed A-compiletest Area: The compiletest test runner A-run-make Area: port run-make Makefiles to rmake.rs A-tidy Area: The tidy tool A-rustc-dev-guide Area: rustc-dev-guide A-compiler-builtins Area: compiler-builtins (https://github.com/rust-lang/compiler-builtins) T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) PG-exploit-mitigations Project group: Exploit mitigations T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Apr 27, 2026
Rust packs rlib metadata into a lib.rmeta archive member encoded as a Mach-O object.

For Apple arm64e, extend the existing metadata-object subtype special case from bare CPU_SUBTYPE_ARM64E to CPU_SUBTYPE_ARM64E | CPU_SUBTYPE_PTRAUTH_ABI.
@cypherair cypherair force-pushed the prep/upstream-ready-arm64e-ptrauth-core-diagnostics-2026-04-24-u9836b06 branch from 77e2e36 to 8c029d5 Compare April 27, 2026 09:39
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 27, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@cypherair
Copy link
Copy Markdown
Contributor Author

Thanks, I’ve removed the test. I really appreciate your time reviewing this and your guidance.

@madsmtm
Copy link
Copy Markdown
Contributor

madsmtm commented Apr 27, 2026

Thanks for fixing this! I've shortened the PR description a bit, and added issues that this fixes.

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 27, 2026

📌 Commit 8c029d5 has been approved by madsmtm

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 27, 2026
@cypherair
Copy link
Copy Markdown
Contributor Author

Thanks again for your review!

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 27, 2026
…4e-ptrauth-core-diagnostics-2026-04-24-u9836b06, r=madsmtm

arm64e: set ptrauth ABI subtype on lib.rmeta Mach-O objects

Set `CPU_SUBTYPE_PTRAUTH_ABI` (as well as the existing `CPU_SUBTYPE_ARM64E`) on ARM64e object files that `rustc` creates, to match Clang/LLVM-generated ARM64e objects.

This corresponds to `cpusubtype == 0x80000002`. Before this change, rustc emitted the bare `CPU_SUBTYPE_ARM64E` subtype for the metadata wrapper objects / `symbols.o` file, producing `0x00000002`, which can be reported by Apple's linker as `arm64e.old`.

Fixes [rust-lang#130085](rust-lang#130085).
Fixes [rust-lang#143844](rust-lang#143844).
Fixes [rust-lang#150046](rust-lang#150046).
Fixes [rust-lang#139218](rust-lang#139218).
rust-bors Bot pushed a commit that referenced this pull request Apr 27, 2026
…uwer

Rollup of 4 pull requests

Successful merges:

 - #152487 (core: drop unmapped ZSTs in array `map`)
 - #155716 (arm64e: set ptrauth ABI subtype on lib.rmeta Mach-O objects)
 - #155864 (Fix panic for doc attributes on where predicates)
 - #155865 (add test for accidentally fixed `binius_field` issue)
rust-bors Bot pushed a commit that referenced this pull request Apr 27, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #154465 (triagebot: Mention 'subtree' in clippy message)
 - #155355 (Fix pathological performance in trait solver cycles with errors)
 - #155716 (arm64e: set ptrauth ABI subtype on lib.rmeta Mach-O objects)
 - #155864 (Fix panic for doc attributes on where predicates)
 - #155865 (add test for accidentally fixed `binius_field` issue)
 - #155866 (Render `ConstContext` for diagnostics once)
@rust-bors rust-bors Bot merged commit df35816 into rust-lang:main Apr 27, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 27, 2026
rust-timer added a commit that referenced this pull request Apr 27, 2026
Rollup merge of #155716 - cypherair:prep/upstream-ready-arm64e-ptrauth-core-diagnostics-2026-04-24-u9836b06, r=madsmtm

arm64e: set ptrauth ABI subtype on lib.rmeta Mach-O objects

Set `CPU_SUBTYPE_PTRAUTH_ABI` (as well as the existing `CPU_SUBTYPE_ARM64E`) on ARM64e object files that `rustc` creates, to match Clang/LLVM-generated ARM64e objects.

This corresponds to `cpusubtype == 0x80000002`. Before this change, rustc emitted the bare `CPU_SUBTYPE_ARM64E` subtype for the metadata wrapper objects / `symbols.o` file, producing `0x00000002`, which can be reported by Apple's linker as `arm64e.old`.

Fixes [#130085](#130085).
Fixes [#143844](#143844).
Fixes [#150046](#150046).
Fixes [#139218](#139218).
@oskarwirga
Copy link
Copy Markdown

My understanding of the ARM64e situation is that it cannot be solved in rustc, it needs LLVM work? Or rather, it needs Apple to upstream their LLVM changes?

Good news is we are not blocked on Apple upstreaming LLVM changes anymore. Currently, end-to-end arm64e support for Rust is chiefly blocked on backend Mach-O support which I put up for review here: llvm/llvm-project#188378

I've been able to successfully build and link arm64e Rust applications using that patch as well this commit where I add support for C/C++ interop w/ appropriate pointer signing schemas: oskarwirga@fbcad35

It should be noted however I am not an expert in rustc and that was put together through trial and error :P

@madsmtm
Copy link
Copy Markdown
Contributor

madsmtm commented Apr 27, 2026

Currently, end-to-end arm64e support for Rust is chiefly blocked on backend Mach-O support which I put up for review here

Ohh, nice work! I'll probably be looking into pointer authentication myself soon as part of reviewing #155722, then I'll probably be able to help with getting things landed in rustc. Feel free to r? madsmtm if you post it as a PR here at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-codegen Area: Code generation O-AArch64 Armv8-A or later processors in AArch64 mode O-apple Operating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

5 participants