Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
saethlin opened this issue Nov 27, 2023 · 0 comments
Open

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

saethlin opened this issue Nov 27, 2023 · 0 comments
Labels
-Zbuild-std Unstable Cargo option: Compile the standard library yourself. A-panic Area: Panicking machinery A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@saethlin
Copy link
Member

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
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 27, 2023
@Noratrieb Noratrieb added A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. -Zbuild-std Unstable Cargo option: Compile the standard library yourself. A-panic Area: Panicking machinery and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 4, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
-Zbuild-std Unstable Cargo option: Compile the standard library yourself. A-panic Area: Panicking machinery A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants