about summary refs log tree commit diff
path: root/library/panic_unwind
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-07-01 18:02:40 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2024-07-01 18:02:40 +0000
commit45b0f68e34c37e5e5f47a1474ad87ebdb099af4b (patch)
tree8e9e0076ff85dc276e1a72a9db35943e6051e863 /library/panic_unwind
parent221e2741c39515a5de6da42d8c76ee1e132c2c74 (diff)
Use the native unwind function in miri where possible
Diffstat (limited to 'library/panic_unwind')
-rw-r--r--library/panic_unwind/src/lib.rs34
1 files changed, 13 insertions, 21 deletions
diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs
index 4dc36120608..77abb9125f6 100644
--- a/library/panic_unwind/src/lib.rs
+++ b/library/panic_unwind/src/lib.rs
@@ -36,18 +36,14 @@ use core::panic::PanicPayload;
 cfg_if::cfg_if! {
     if #[cfg(target_os = "emscripten")] {
         #[path = "emcc.rs"]
-        mod real_imp;
+        mod imp;
     } else if #[cfg(target_os = "hermit")] {
         #[path = "hermit.rs"]
-        mod real_imp;
+        mod imp;
     } else if #[cfg(target_os = "l4re")] {
         // L4Re is unix family but does not yet support unwinding.
         #[path = "dummy.rs"]
-        mod real_imp;
-    } else if #[cfg(all(target_env = "msvc", not(target_arch = "arm")))] {
-        // LLVM does not support unwinding on 32 bit ARM msvc (thumbv7a-pc-windows-msvc)
-        #[path = "seh.rs"]
-        mod real_imp;
+        mod imp;
     } else if #[cfg(any(
         all(target_family = "windows", target_env = "gnu"),
         target_os = "psp",
@@ -58,7 +54,16 @@ cfg_if::cfg_if! {
         target_family = "wasm",
     ))] {
         #[path = "gcc.rs"]
-        mod real_imp;
+        mod imp;
+    } else if #[cfg(miri)] {
+        // Use the Miri runtime on Windows as miri doesn't support funclet based unwinding,
+        // only landingpad based unwinding. Also use the Miri runtime on unsupported platforms.
+        #[path = "miri.rs"]
+        mod imp;
+    } else if #[cfg(all(target_env = "msvc", not(target_arch = "arm")))] {
+        // LLVM does not support unwinding on 32 bit ARM msvc (thumbv7a-pc-windows-msvc)
+        #[path = "seh.rs"]
+        mod imp;
     } else {
         // Targets that don't support unwinding.
         // - os=none ("bare metal" targets)
@@ -67,20 +72,7 @@ cfg_if::cfg_if! {
         // - nvptx64-nvidia-cuda
         // - arch=avr
         #[path = "dummy.rs"]
-        mod real_imp;
-    }
-}
-
-cfg_if::cfg_if! {
-    if #[cfg(miri)] {
-        // Use the Miri runtime.
-        // We still need to also load the normal runtime above, as rustc expects certain lang
-        // items from there to be defined.
-        #[path = "miri.rs"]
         mod imp;
-    } else {
-        // Use the real runtime.
-        use real_imp as imp;
     }
 }