rust/compiler/rustc_codegen_gcc/src
bors 4056082360 Auto merge of #146317 - saethlin:panic=immediate-abort, r=nnethercote
Add panic=immediate-abort

MCP: https://github.com/rust-lang/compiler-team/issues/909

This adds a new panic strategy, `-Cpanic=immediate-abort`. This panic strategy essentially just codifies use of `-Zbuild-std-features=panic_immediate_abort`. This PR is intended to just set up infrastructure, and while it will change how the compiler is invoked for users of the feature, there should be no other impacts.

In many parts of the compiler, `PanicStrategy::ImmediateAbort` behaves just like `PanicStrategy::Abort`, because actually most parts of the compiler just mean to ask "can this unwind?" so I've added a helper function so we can say `sess.panic_strategy().unwinds()`.

The panic and unwind strategies have some level of compatibility, which mostly means that we can pre-compile the sysroot with unwinding panics then the sysroot can be linked with aborting panics later. The immediate-abort strategy is all-or-nothing, enforced by `compiler/rustc_metadata/src/dependency_format.rs` and this is tested for in `tests/ui/panic-runtime/`. We could _technically_ be more compatible with the other panic strategies, but immediately-aborting panics primarily exist for users who want to eliminate all the code size responsible for the panic runtime. I'm open to other use cases if people want to present them, but not right now. This PR is already large.

`-Cpanic=immediate-abort` sets both `cfg(panic = "immediate-abort")` _and_ `cfg(panic = "abort")`. bjorn3 pointed out that people may be checking for the abort cfg to ask if panics will unwind, and also the sysroot feature this is replacing used to require `-Cpanic=abort` so this seems like a good back-compat step. At least for the moment. Unclear if this is a good idea indefinitely. I can imagine this being confusing.

The changes to the standard library attributes are purely mechanical. Apart from that, I removed an `unsafe` we haven't needed for a while since the `abort` intrinsic became safe, and I've added a helpful diagnostic for people trying to use the old feature.

To test that `-Cpanic=immediate-abort` conflicts with other panic strategies, I've beefed up the core-stubs infrastructure a bit. There is now a separate attribute to set flags on it.

I've added a test that this produces the desired codegen, called `tests/run-make-cargo/panic-immediate-abort-codegen/` and also a separate run-make-cargo test that checks that we can build a binary.
2025-09-23 06:37:03 +00:00
..
back Remove want_summary argument from prepare_thin 2025-09-06 18:37:23 +00:00
intrinsic Add panic=immediate-abort 2025-09-21 13:12:18 -04:00
abi.rs Merge commit '4b5c44b141' into subtree-update_cg_gcc_2025-06-30 2025-06-30 16:12:42 +02:00
allocator.rs Merge commit '482e8540a1' into subtree-update_cg_gcc_2025-08-04 2025-08-04 10:49:43 +02:00
asm.rs Support ctr and lr as clobber-only registers in PowerPC inline assembly 2025-09-21 13:48:22 +09:00
attributes.rs remove rustc_attr_data_structures 2025-07-31 14:19:27 +02:00
base.rs Add panic=immediate-abort 2025-09-21 13:12:18 -04:00
builder.rs Rollup merge of #144192 - RalfJung:atomicrmw-ptr, r=nikic 2025-08-08 14:22:44 -05:00
callee.rs remove rustc_attr_data_structures 2025-07-31 14:19:27 +02:00
common.rs Add opaque TypeId handles for CTFE 2025-07-09 16:37:11 +00:00
consts.rs allow #[rustc_align_static(N)] on statics 2025-09-09 21:54:54 +02:00
context.rs Merge commit '4b5c44b141' into subtree-update_cg_gcc_2025-06-30 2025-06-30 16:12:42 +02:00
coverageinfo.rs Unbox and unwrap the contents of StatementKind::Coverage 2024-03-23 22:05:11 +11:00
debuginfo.rs Revert "Preserve the .debug_gdb_scripts section" 2025-08-06 18:01:07 +00:00
declare.rs Merge commit 'b7091eca6d' into subtree-update_cg_gcc_2025-06-28 2025-06-28 23:37:08 +02:00
errors.rs Implement support for explicit tail calls in the MIR block builders and the LLVM codegen backend. 2025-07-26 01:02:29 +02:00
gcc_util.rs various minor target feature cleanups 2025-06-19 10:50:03 +09:00
int.rs Merge commit '482e8540a1' into subtree-update_cg_gcc_2025-08-04 2025-08-04 10:49:43 +02:00
lib.rs Remove want_summary argument from prepare_thin 2025-09-06 18:37:23 +00:00
mono_item.rs Port the #[linkage] attribute to the new attribute system 2025-08-13 21:01:37 +02:00
type_.rs Merge commit 'fda0bb9588' into subtree-update_cg_gcc_2025-06-18 2025-06-18 15:11:44 +02:00
type_of.rs erase_regions to erase_and_anonymize_regions 2025-09-09 14:49:16 +02:00