Thanks to visit codestin.com
Credit goes to github.com

Skip to content

aarch64-linux: Default to FramePointer::NonLeaf #140832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

workingjubilee
Copy link
Member

For aarch64-apple and aarch64-windows, platform docs state that code must use frame pointers correctly. This is because the AAPCS64 mandates that a platform specify its frame pointer conformance requirements:

Unwinding code either requires unwind tables or frame pointers, and on aarch64 the expectation is that one can use frame pointers for this. Most Linux targets represent a motley variety of possible distributions, so it is unclear who to defer to on conformance, other than perhaps Arm. In the absence of a specific edict for a given aarch64-linux target, Rust will assume aarch64-linux targets also use non-leaf frame pointers.

r? ghost

try-job: aarch64-gnu
try-job: aarch64-gnu-debug
try-job: arm-android
try-job: armhf-gnu
try-job: dist-aarch64-linux
try-job: dist-ohos
try-job: test-various

@rustbot rustbot added 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 May 8, 2025
@workingjubilee workingjubilee force-pushed the aarch64-linux-should-use-frame-pointers branch from 1af6325 to fbaf582 Compare May 8, 2025 21:58
@workingjubilee
Copy link
Member Author

@bors try

@bors
Copy link
Collaborator

bors commented May 8, 2025

⌛ Trying commit fbaf582 with merge b5f9a0d36e6b3537b76a5aa710e1d5d13313f3d1...

bors added a commit to rust-lang-ci/rust that referenced this pull request May 8, 2025
…use-frame-pointers, r=<try>

aarch64-linux: Default to FramePointer::NonLeaf

For aarch64-apple and aarch64-windows, platform docs state that code must use frame pointers correctly. This is because the AAPCS64 mandates that a platform specify its frame pointer conformance requirements:
- Apple: https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Respect-the-purpose-of-specific-CPU-registers
- Windows: https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers
- AAPCS64: https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer

Unwinding code either requires unwind tables or frame pointers, and on aarch64 the expectation is that one can use frame pointers for this. Most Linux targets represent a motley variety of possible distributions, so it is unclear who to defer to on conformance, other than perhaps Arm. In the absence of a specific edict for a given aarch64-linux target, Rust will assume aarch64-linux targets also use non-leaf frame pointers.

r? ghost

try-job: aarch64-gnu
try-job: aarch64-gnu-debug
try-job: arm-android
try-job: armhf-gnu
try-job: dist-aarch64-linux
try-job: dist-ohos
try-job: test-various
@rust-log-analyzer

This comment has been minimized.

For aarch64-apple and aarch64-windows, platform docs state that code
must use frame pointers correctly. This is because the AAPCS64 mandates
that a platform specify its frame pointer conformance requirements:
- Apple: https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Respect-the-purpose-of-specific-CPU-registers
- Windows: https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers
- AAPCS64: https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer

Unwinding code either requires unwind tables or frame pointers, and
on aarch64 the expectation is that one can use frame pointers for this.
Most Linux targets represent a motley variety of possible distributions,
so it is unclear who to defer to on conformance, other than perhaps Arm.
In the absence of a specific edict for a given aarch64-linux target,
Rust will assume aarch64-linux targets use non-leaf frame pointers.
@workingjubilee workingjubilee force-pushed the aarch64-linux-should-use-frame-pointers branch from fbaf582 to 89ad6c3 Compare May 8, 2025 22:44
@workingjubilee
Copy link
Member Author

@bors try

@bors
Copy link
Collaborator

bors commented May 8, 2025

⌛ Trying commit 89ad6c3 with merge 08309a2...

bors added a commit to rust-lang-ci/rust that referenced this pull request May 8, 2025
…use-frame-pointers, r=<try>

aarch64-linux: Default to FramePointer::NonLeaf

For aarch64-apple and aarch64-windows, platform docs state that code must use frame pointers correctly. This is because the AAPCS64 mandates that a platform specify its frame pointer conformance requirements:
- Apple: https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Respect-the-purpose-of-specific-CPU-registers
- Windows: https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers
- AAPCS64: https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer

Unwinding code either requires unwind tables or frame pointers, and on aarch64 the expectation is that one can use frame pointers for this. Most Linux targets represent a motley variety of possible distributions, so it is unclear who to defer to on conformance, other than perhaps Arm. In the absence of a specific edict for a given aarch64-linux target, Rust will assume aarch64-linux targets also use non-leaf frame pointers.

r? ghost

try-job: aarch64-gnu
try-job: aarch64-gnu-debug
try-job: arm-android
try-job: armhf-gnu
try-job: dist-aarch64-linux
try-job: dist-ohos
try-job: test-various
@workingjubilee
Copy link
Member Author

cc re: OpenHarmony: @Amanieu @lubinglun
cc re: Android: @chriswailes @maurer @mgeisler

I assume there's no objections to doing this? I can revert the change for your particular aarch64-linux targets if you want.

@rust-log-analyzer

This comment was marked as outdated.

@Amanieu
Copy link
Member

Amanieu commented May 8, 2025

I assume there's no objections to doing this? I can revert the change for your particular aarch64-linux targets if you want.

No specific objection for OpenHarmony, though I have a more general objection.

For aarch64-apple and aarch64-windows, platform docs state that code must use frame pointers correctly. This is because the AAPCS64 mandates that a platform specify its frame pointer conformance requirements:

While this is required on Windows & Apple as per their docs, Linux doesn't actually specify whether a frame pointer is required and I would assume the default assumption is that it isn't since that is the default setting on GCC for aarch64-linux.

AAPCS64 explicitly allows this as an option:

It may elect not to maintain a frame chain and to use the frame pointer register as a general-purpose callee-saved register.

@workingjubilee
Copy link
Member Author

@Amanieu What authority would you defer to? Who is gonna specify that requirement? Should we ask Linus Torvalds?

@workingjubilee
Copy link
Member Author

workingjubilee commented May 8, 2025

The aarch64-unknown-linux-gnu target was added raised to tier 1 at the behest of Arm, so if you don't have an answer to that, then the answer is the buck stops either with us or with Arm. We can add more process to this decision for an MCP or something, to see if we have a consensus for ourselves on what we should do, but "the platform is allowed to specify something other than maximal conformance" must not be allowed to combine with "no one decides because the definition of who 'owns' the platform is ambiguous" to result in "Rust chooses inaction".

Unless we intend to remove the aarch64-unknown-linux-gnu target, I suppose, but that would make people much more mad.

@Amanieu
Copy link
Member

Amanieu commented May 8, 2025

Actually I just checked and it seems that I am incorrect: the default on AArch64 Linux for both GCC and Clang is to enable frame pointers for non-leaf functions. I withdraw my objection.

Regarding authority, the target owner is Arm so they get the final say. However I would imagine that they would want to match the behavior of C compilers which they also contribute to.

@workingjubilee
Copy link
Member Author

Ah, well, yes, I would agree, I just figured the answer from Arm was the obvious one ("it puts the frame pointer in the register or else it gets the hose again")

@bors
Copy link
Collaborator

bors commented May 9, 2025

☀️ Try build successful - checks-actions
Build commit: 08309a2 (08309a214d769a277a7ecc5287b9a39fc71006b6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants