Fix backtraces with -C panic=abort on linux; emit unwind tables by default by Enselic · Pull Request #143613 · rust-lang/rust (original) (raw)
The linux backtrace unwinder relies on unwind tables to work properly, and generating and printing a backtrace is done by for example the default panic hook.
Begin emitting unwind tables by default again with -C panic=abort (see history below) so that backtraces work.
Closes #81902 which is regression-from-stable-to-stable
Closes #94815
History
Backtraces with -C panic=abort used to work in Rust 1.22 but broke in Rust 1.23, because in 1.23 we stopped emitting unwind tables with -C panic=abort (see #45031 and #81902 (comment)).
In 1.45 a workaround in the form of -C force-unwind-tables=yes was added (see #69984).
-C panic=abort was added in Rust 1.10 and the motivation was binary size and compile time. But given how confusing that behavior has turned out to be, it is better to make binary size optimization opt-in with -C force-unwind-tables=no rather than default since the current default breaks backtraces.
Besides, if binary size is a primary concern, there are many other tricks that can be used that has a higher impact.
Release Note Entry Draft:
Compatibility Notes
- Fix backtraces with -C panic=abort on Linux by generating unwind tables by default. Build with
-C force-unwind-tables=noto keep omitting unwind tables.
try-job: aarch64-apple
try-job: armhf-gnu
try-job: aarch64-msvc-1