Auto merge of #70010 - Amanieu:fix-opt-catch, r=Mark-Simulacrum
Add a workaround for catch_unwind in stage1 mingw target Fixes #70001 cc @petrochenkov r? @Mark-Simulacrum
This commit is contained in:
commit
8e6de3244c
1 changed files with 29 additions and 27 deletions
|
@ -277,15 +277,16 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
|
|||
Err(ManuallyDrop::into_inner(data.p))
|
||||
};
|
||||
|
||||
// Compatibility wrapper around the try intrinsic for bootstrap
|
||||
#[inline]
|
||||
unsafe fn do_try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32 {
|
||||
// Compatibility wrapper around the try intrinsic for bootstrap.
|
||||
//
|
||||
// We also need to mark it #[inline(never)] to work around a bug on MinGW
|
||||
// targets: the unwinding implementation was relying on UB, but this only
|
||||
// becomes a problem in practice if inlining is involved.
|
||||
#[cfg(not(bootstrap))]
|
||||
{
|
||||
intrinsics::r#try(try_fn, data, catch_fn)
|
||||
}
|
||||
use intrinsics::r#try as do_try;
|
||||
#[cfg(bootstrap)]
|
||||
{
|
||||
#[inline(never)]
|
||||
unsafe fn do_try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32 {
|
||||
use crate::mem::MaybeUninit;
|
||||
#[cfg(target_env = "msvc")]
|
||||
type TryPayload = [u64; 2];
|
||||
|
@ -307,7 +308,6 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
|
|||
}
|
||||
r
|
||||
}
|
||||
}
|
||||
|
||||
// We consider unwinding to be rare, so mark this function as cold. However,
|
||||
// do not mark it no-inline -- that decision is best to leave to the
|
||||
|
@ -320,7 +320,9 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
|
|||
obj
|
||||
}
|
||||
|
||||
#[inline]
|
||||
// See comment on do_try above for why #[inline(never)] is needed on bootstrap.
|
||||
#[cfg_attr(bootstrap, inline(never))]
|
||||
#[cfg_attr(not(bootstrap), inline)]
|
||||
fn do_call<F: FnOnce() -> R, R>(data: *mut u8) {
|
||||
unsafe {
|
||||
let data = data as *mut Data<F, R>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue