77//@ [aarch64-apple-on] compile-flags: --target=aarch64-apple-darwin -Cforce-frame-pointers=on
88//@ [aarch64-apple-off] needs-llvm-components: aarch64
99//@ [aarch64-apple-off] compile-flags: --target=aarch64-apple-darwin -Cforce-frame-pointers=off
10- /*
11- Tests that the frame pointers can be controlled by the CLI. We find aarch64-apple-darwin useful
12- because of its icy-clear policy regarding frame pointers (software SHALL be compiled with them),
13- e.g. https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms says:
10+ /*!
11+
12+ Tests the extent to which frame pointers can be controlled by the CLI.
13+ The behavior of our frame pointer options, at present, is an irreversible ratchet, where
14+ a "weaker" option that allows omitting frame pointers may be overridden by the target demanding
15+ that all code (or all non-leaf code, more often) must be compiled with frame pointers.
16+ This was discussed on 2025-05-25 in the T-compiler meeting and accepted as an intentional change,
17+ ratifying the prior decisions by compiler contributors and reviewers as correct,
18+ though it was also acknowledged that the flag allows somewhat confusing inputs.
19+
20+ We find aarch64-apple-darwin useful because of its icy-clear policy regarding frame pointers,
21+ e.g. <https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms> says:
1422
1523* The frame pointer register (x29) must always address a valid frame record. Some functions —
1624 such as leaf functions or tail calls — may opt not to create an entry in this list.
1725 As a result, stack traces are always meaningful, even without debug information.
26+
27+ Many Rust fn, if externally visible, may be expected to follow target ABI by tools or asm code!
28+ This can make it a problem to generate ABI-incorrect code, which may mean "with frame pointers".
29+ For this and other reasons, `-Cforce-frame-pointers=off` cannot override the target definition.
30+ This can cause some confusion because it is "reverse polarity" relative to C compilers, which have
31+ commands like `-fomit-frame-pointer`, `-fomit-leaf-frame-pointer`, or `-fno-omit-frame-pointer`!
32+
33+ Specific cases where platforms or tools rely on frame pointers for sound or correct unwinding:
34+ - illumos: <https://smartos.org/bugview/OS-7515>
35+ - aarch64-windows: <https://github.com/rust-lang/rust/issues/123686>
36+ - aarch64-linux: <https://github.com/rust-lang/rust/issues/123733>
37+ - dtrace (freebsd and openbsd): <https://github.com/rust-lang/rust/issues/97723>
38+ - openbsd: <https://github.com/rust-lang/rust/issues/43575>
39+ - i686-msvc <https://github.com/rust-lang/backtrace-rs/pull/584#issuecomment-1966177530>
40+ - i686-mingw: <https://github.com/rust-lang/rust/commit/3f1d3948d6d434b34dd47f132c126a6cb6b8a4ab>
1841*/
1942#![ feature( no_core, lang_items) ]
2043#![ no_core]
@@ -34,5 +57,7 @@ pub fn peach(x: u32) -> u32 {
3457// force-on-SAME: {{.*}}"frame-pointer"="all"
3558// aarch64-apple-SAME: {{.*}}"frame-pointer"="non-leaf"
3659// aarch64-apple-on-SAME: {{.*}}"frame-pointer"="all"
37- // aarch64-apple-off-NOT: {{.*}}"frame-pointer"{{.*}}
60+ //
61+ // yes, we are testing this doesn't do anything:
62+ // aarch64-apple-off-SAME: {{.*}}"frame-pointer"="non-leaf"
3863// CHECK-SAME: }
0 commit comments