Skip to content

Add codegen test(s) for -Zbuild-std-features=panic_immediate_abort #118393

Open
@saethlin

Description

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.

  1. Put together from scratch or find a small Cargo project, and build it using the above flags except without -Zbuild-std-features
  2. 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 and Vec::remove, the ones for RefCell, maybe others?)
  3. Rebuild the project but with -Zbuild-std-features=panic_immediate_abort and check that all those symbols are gone

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    -Zbuild-stdUnstable Cargo option: Compile the standard library yourself.A-panicArea: Panicking machineryA-testsuiteArea: The testsuite used to check the correctness of rustcC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions