Skip to content

Commit f8caf5f

Browse files
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 03d11c2 + 1dc4f05 commit f8caf5f

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

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

0 commit comments

Comments
 (0)