diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 010ae42c2802d..60a3c4d889204 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -704,6 +704,11 @@ impl Session { /// Returns the panic strategy for this compile session. If the user explicitly selected one /// using '-C panic', use that, otherwise use the panic strategy defined by the target. pub fn panic_strategy(&self) -> PanicStrategy { + if self.opts.crate_name.as_deref() == Some("panic_abort") { + // The panic_abort crate must always be compiled with panic=abort. + return PanicStrategy::Abort; + } + self.opts.cg.panic.unwrap_or(self.target.panic_strategy) } diff --git a/src/bootstrap/src/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs index d8cae02456c0e..df4f3bf83ee3a 100644 --- a/src/bootstrap/src/bin/rustc.rs +++ b/src/bootstrap/src/bin/rustc.rs @@ -161,7 +161,8 @@ fn main() { // This... is a bit of a hack how we detect this. Ideally this // information should be encoded in the crate I guess? Would likely // require an RFC amendment to RFC 1513, however. - if crate_name == Some("panic_abort") { + // cfg(not(bootstrap)) + if crate_name == Some("panic_abort") && stage == "0" { cmd.arg("-C").arg("panic=abort"); }