|
10 | 10 | /*
|
11 | 11 | Tests that the frame pointers can be controlled by the CLI. We find aarch64-apple-darwin useful
|
12 | 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: |
| 13 | +e.g. <https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms> says: |
14 | 14 |
|
15 | 15 | * The frame pointer register (x29) must always address a valid frame record. Some functions —
|
16 | 16 | such as leaf functions or tail calls — may opt not to create an entry in this list.
|
17 | 17 | As a result, stack traces are always meaningful, even without debug information.
|
18 | 18 | */
|
| 19 | +// Want the links to be clickable? Try: |
| 20 | +// rustdoc +nightly ./tests/codegen/frame-pointer-cli-control.rs --out-dir=dilemma && xdg-open ./dilemma/frame_pointer_cli_control/index.htm |
| 21 | +//! |
| 22 | +//! TODO: T-compiler needs to make a decision about whether or not rustc should defer to the CLI |
| 23 | +//! when given the -Cforce-frame-pointers flag, even when the target platform mandates it for ABI! |
| 24 | +//! Considerations: |
| 25 | +//! |
| 26 | +//! - Many Rust fn, if externally visible, may be expected to follow ABI by tools or even asm code! |
| 27 | +//! This can potentially make it unsound to generate ABI-incorrect (without frame pointers) code. |
| 28 | +//! - Some platforms (e.g. illumos) seem to have unwinding completely break without frame-pointers: |
| 29 | +//! - <https://smartos.org/bugview/OS-7515> |
| 30 | +//! - <https://github.com/rust-lang/rust/blob/b71e8cbaf2c7cae4d36898fff1d0ba19d9233082/compiler/rustc_target/src/spec/base/illumos.rs#L35> |
| 31 | +//! - The code in more sophisticated backtrace and unwinding routines is notorious "dark magic" |
| 32 | +//! that is poorly documented, understood by few, and prone to regressions for strange reasons. |
| 33 | +//! Such unwinders in-theory allow using uwutables instead of frame pointers, but if they break? |
| 34 | +//! For better or worse, these problems are often mended by forcing frame pointers: |
| 35 | +//! - <https://github.com/rust-lang/rust/issues/123733> |
| 36 | +//! - <https://github.com/rust-lang/rust/issues/104388> |
| 37 | +//! - <https://github.com/rust-lang/rust/issues/97723> |
| 38 | +//! - <https://github.com/rust-lang/rust/issues/43575> |
| 39 | +//! - Those 32-bit x86 platforms that reputedly benefit the most from omitting frame pointers? |
| 40 | +//! They also suffer the most from doing so, because of ancient unwinding/backtrace handling: |
| 41 | +//! - <https://github.com/rust-lang/backtrace-rs/pull/624#issuecomment-2109962234> |
| 42 | +//! - <https://github.com/rust-lang/backtrace-rs/pull/584#issuecomment-1952006125> |
| 43 | +//! - <https://github.com/rust-lang/backtrace-rs/pull/601> |
| 44 | +//! - <https://github.com/rust-lang/rust/commit/3f1d3948d6d434b34dd47f132c126a6cb6b8a4ab> |
| 45 | +//! - Omitting frame-pointers may not meaningfully impact -Cpanic=abort binaries in function, but |
| 46 | +//! some targets that default to panic=abort do force frame pointers to allow debugging to work, |
| 47 | +//! even when they are notably pressed for space: |
| 48 | +//! - <https://github.com/rust-lang/rust/blob/b71e8cbaf2c7cae4d36898fff1d0ba19d9233082/compiler/rustc_target/src/spec/base/thumb.rs#L51-L53> |
| 49 | +//! - There is, of course, the question of whether this compiler option was ever a good idea? |
| 50 | +//! Some would say no: <https://www.brendangregg.com/blog/2024-03-17/the-return-of-the-frame-pointers.html> |
| 51 | +//! - Despite all other remarks, it is true that the previous behavior was to defer to the CLI! |
| 52 | +//! It may be considered a regression, but perhaps some platforms rely on that "regression". |
| 53 | +//! Note the current behavior does uphold the doc's "without reading the source" contract: |
| 54 | +//! - <https://github.com/rust-lang/rust/blob/9e7aff794539aa040362f4424eb29207449ffce0/src/doc/rustc/src/codegen-options/index.md?plain=1#L157-L165> |
| 55 | +
|
19 | 56 | #![feature(no_core, lang_items)]
|
20 | 57 | #![no_core]
|
21 | 58 | #[lang = "sized"]
|
|
0 commit comments