Skip to content

Commit 8a35c4e

Browse files
authored
Unrolled build for rust-lang#127214
Rollup merge of rust-lang#127214 - bjorn3:miri_native_unwind, r=oli-obk Use the native unwind function in miri where possible Continuation of rust-lang/miri#3319 cc `@RalfJung`
2 parents 2ad6630 + e03c3b6 commit 8a35c4e

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

library/panic_unwind/src/lib.rs

+13-21
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,14 @@ use core::panic::PanicPayload;
3636
cfg_if::cfg_if! {
3737
if #[cfg(target_os = "emscripten")] {
3838
#[path = "emcc.rs"]
39-
mod real_imp;
39+
mod imp;
4040
} else if #[cfg(target_os = "hermit")] {
4141
#[path = "hermit.rs"]
42-
mod real_imp;
42+
mod imp;
4343
} else if #[cfg(target_os = "l4re")] {
4444
// L4Re is unix family but does not yet support unwinding.
4545
#[path = "dummy.rs"]
46-
mod real_imp;
47-
} else if #[cfg(all(target_env = "msvc", not(target_arch = "arm")))] {
48-
// LLVM does not support unwinding on 32 bit ARM msvc (thumbv7a-pc-windows-msvc)
49-
#[path = "seh.rs"]
50-
mod real_imp;
46+
mod imp;
5147
} else if #[cfg(any(
5248
all(target_family = "windows", target_env = "gnu"),
5349
target_os = "psp",
@@ -58,7 +54,16 @@ cfg_if::cfg_if! {
5854
target_family = "wasm",
5955
))] {
6056
#[path = "gcc.rs"]
61-
mod real_imp;
57+
mod imp;
58+
} else if #[cfg(miri)] {
59+
// Use the Miri runtime on Windows as miri doesn't support funclet based unwinding,
60+
// only landingpad based unwinding. Also use the Miri runtime on unsupported platforms.
61+
#[path = "miri.rs"]
62+
mod imp;
63+
} else if #[cfg(all(target_env = "msvc", not(target_arch = "arm")))] {
64+
// LLVM does not support unwinding on 32 bit ARM msvc (thumbv7a-pc-windows-msvc)
65+
#[path = "seh.rs"]
66+
mod imp;
6267
} else {
6368
// Targets that don't support unwinding.
6469
// - os=none ("bare metal" targets)
@@ -67,20 +72,7 @@ cfg_if::cfg_if! {
6772
// - nvptx64-nvidia-cuda
6873
// - arch=avr
6974
#[path = "dummy.rs"]
70-
mod real_imp;
71-
}
72-
}
73-
74-
cfg_if::cfg_if! {
75-
if #[cfg(miri)] {
76-
// Use the Miri runtime.
77-
// We still need to also load the normal runtime above, as rustc expects certain lang
78-
// items from there to be defined.
79-
#[path = "miri.rs"]
8075
mod imp;
81-
} else {
82-
// Use the real runtime.
83-
use real_imp as imp;
8476
}
8577
}
8678

src/tools/miri/src/shims/windows/foreign_items.rs

+16
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,22 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
758758
this.write_null(dest)?;
759759
}
760760

761+
"_Unwind_RaiseException" => {
762+
// This is not formally part of POSIX, but it is very wide-spread on POSIX systems.
763+
// It was originally specified as part of the Itanium C++ ABI:
764+
// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html#base-throw.
765+
// MinGW implements _Unwind_RaiseException on top of SEH exceptions.
766+
if this.tcx.sess.target.env != "gnu" {
767+
throw_unsup_format!(
768+
"`_Unwind_RaiseException` is not supported on non-MinGW Windows",
769+
);
770+
}
771+
// This function looks and behaves excatly like miri_start_unwind.
772+
let [payload] = this.check_shim(abi, Abi::C { unwind: true }, link_name, args)?;
773+
this.handle_miri_start_unwind(payload)?;
774+
return Ok(EmulateItemResult::NeedsUnwind);
775+
}
776+
761777
_ => return Ok(EmulateItemResult::NotSupported),
762778
}
763779

0 commit comments

Comments
 (0)