Make rustc implicitly use panic=abort for the panic_abort crate by bjorn3 · Pull Request #140254 · rust-lang/rust (original) (raw)
It's less of a practical concern, but shouldn't panic_unwind also implicitly use panic=unwind?
If panic=abort was used while compiling the standard library, panic_unwind won't be used anyway as any panic=abort dependency will force panic=abort to be used and thus panic_unwind doesn't get linked in.
I guess the proper solution would be to move fn panic_strategy from sess to tcx so it can use tcx.is_panic_runtime(), and extend the #![panic_runtime] attribute to #![panic_runtime = "abort|unwind"] to avoid relying on the crate name.
What do you think?
The LLVM backend needs to know if the current crate uses panic=unwind or panic=abort before any source code gets parsed:
&& sess.panic_strategy() == PanicStrategy::Unwind |
---|
Ah, crate loader still searches for panic_(unwind,abort) by crate name, but we can at least sanity check that the crate found that way is indeed #![panic_runtime = "unwind" or "abort"] respectively.
There already is a sanity check that the found crate is a panic runtime:
if !data.is_panic_runtime() { |
---|
self.dcx().emit_err(errors::CrateNotPanicRuntime { crate_name: name }); |
} |