Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9a1dfd2

Browse files
committedApr 30, 2021
Auto merge of rust-lang#84722 - pnkfelix:address-c-unwind-via-backport-of-84158, r=Mark-Simulacrum
backport: move new c abi abort behavior behind feature gate This is a backport of PR rust-lang#84158 to the beta branch. The original T-compiler plan was to revert PR rust-lang#76570 in its entirety, as was attempted in PR rust-lang#84672. But the revert did not go smoothly (details below). Therefore, we are backporting PR rust-lang#84158 instead, which was our established backup plan if a revert did not go smoothly. I have manually confirmed that this backport fixes the luajit issue described on issue rust-lang#83541 <details> <summary>Click for details as to why revert of PR rust-lang#76570 did not go smoothly.</summary> It turns out that Miri had been subsequently updated to reflect changes to `rustc_target` that landed in PR rust-lang#76570. This meant that the attempt to land PR rust-lang#84672 broke Miri builds. Normally we allow tools to break when landing PR's (and just expect follow-up PR's to fix the tools), but we don't allow it for tools in the run-up to a release. (We shouldn't be using that uniform policy for all tools. Miri should be allow to break during the week before a release; but currently we cannot express that, due to issue rust-lang#74709.) Therefore, its a lot of pain to try to revert PR rust-lang#76570. And we're going with the backup plan. </details> Original commit message follows: ---- *Background* In rust-lang#76570, new ABI strings including `C-unwind` were introduced. Their behavior is specified in RFC 2945 <sup>[1]</sup>. However, it was reported in the #ffi-unwind stream of the Rust community Zulip that this had altered the way that `extern "C"` functions behaved even when the `c_unwind` feature gate was not active. <sup>[2]</sup> *Overview* This makes a small patch to `rustc_mir_build::build::should_abort_on_panic`, so that the same behavior from before is in place when the `c_unwind` gate is not active. `rustc_middle::ty::layout::fn_can_unwind` is not touched, as the visible behavior should not differ before/after rust-lang#76570. <sup>[3]</sup> ### Footnotes 1.: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md 2.: https://rust-lang.zulipchat.com/#narrow/stream/210922-project-ffi-unwind/topic/Is.20unwinding.20through.20extern.20C.20UB.3F/near/230112325 3.: https://github.com/rust-lang/rust/pull/76570/files#diff-b0320c2b8868f325d83c027fc5d71732636e9763551e35895488f30fe057c6e9L2599-R2617 [1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md [2]: https://rust-lang.zulipchat.com/#narrow/stream/210922-project-ffi-unwind/topic/Is.20unwinding.20through.20extern.20C.20UB.3F/near/230112325 [3]: https://github.com/rust-lang/rust/pull/76570/files#diff-b0320c2b8868f325d83c027fc5d71732636e9763551e35895488f30fe057c6e9L2599-R2617
2 parents f97769a + 8341f42 commit 9a1dfd2

File tree

1 file changed

+5
-1
lines changed
  • compiler/rustc_mir_build/src/build

1 file changed

+5
-1
lines changed
 

‎compiler/rustc_mir_build/src/build/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: LocalDefId, abi: Abi) -> bo
579579
Some(UnwindAttr::Aborts) => true,
580580
// If no attribute was found and the panic strategy is `unwind`, then we should examine
581581
// the function's ABI string to determine whether it should abort upon panic.
582-
None => {
582+
None if tcx.features().c_unwind => {
583583
use Abi::*;
584584
match abi {
585585
// In the case of ABI's that have an `-unwind` equivalent, check whether the ABI
@@ -609,6 +609,10 @@ fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: LocalDefId, abi: Abi) -> bo
609609
| Unadjusted => true,
610610
}
611611
}
612+
// If the `c_unwind` feature gate is not active, follow the behavior that was in place
613+
// prior to #76570. This is a special case: some functions have a C ABI but are meant to
614+
// unwind anyway. Don't stop them.
615+
None => false, // FIXME(#58794); should be `!(abi == Abi::Rust || abi == Abi::RustCall)`
612616
}
613617
}
614618

0 commit comments

Comments
 (0)
Please sign in to comment.