Add codegen test(s) for -Zbuild-std-features=panic_immediate_abort #118393
Open
Description
opened on Nov 27, 2023
The standard library has a feature panic_immediate_abort
which is for use with -Zbuild-std
to eliminate all the panic formatting code. As a result, we have a lot of checks for that feature across the library code, to remove #[inline(never)]
when that feature is enabled, so that panic helpers can be inlined and optimized away.
There are no tests for whether this actually works. I know it mostly works, because I just checked manually. What I did was something like this:
RUSTFLAGS="-Cdebuginfo=1 -Cstrip=none -Cpanic=abort -Cembed-bitcode=yes -Clto=fat" cargo +nightly install cargo-nextest -Zbuild-std=panic_abort,std -Zbuild-std-features=panic_immediate_abort --target=x86_64-unknown-linux-gnu --force
nm ~/.cargo/bin/cargo-nextest | grep panic | grep rustfilt
What comes out is this:
00000000002a1410 t color_eyre::config::panic_verbosity
00000000002a12f0 t color_eyre::config::PanicHook::into_panic_hook::{{closure}}
000000000091e568 b std::panicking::HOOK
00000000002a1110 t core::ptr::drop_in_place<color_eyre::config::PanicHook::into_panic_hook::{{closure}}>
That looks acceptable to me.
Someone should use this general procedure to build a test.
- Put together from scratch or find a small Cargo project, and build it using the above flags except without
-Zbuild-std-features
- Write a check that the binary that comes out has everything in a list of panic symbols (the bouds check ones, the ones for
Vec::insert
andVec::remove
, the ones forRefCell
, maybe others?) - Rebuild the project but with
-Zbuild-std-features=panic_immediate_abort
and check that all those symbols are gone
Activity