about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libpanic_unwind/lib.rs20
-rw-r--r--src/libstd/build.rs26
-rw-r--r--src/libunwind/lib.rs36
3 files changed, 62 insertions, 20 deletions
diff --git a/src/libpanic_unwind/lib.rs b/src/libpanic_unwind/lib.rs
index 26b503cb792..430062d4ac4 100644
--- a/src/libpanic_unwind/lib.rs
+++ b/src/libpanic_unwind/lib.rs
@@ -41,21 +41,33 @@ cfg_if::cfg_if! {
     if #[cfg(target_os = "emscripten")] {
         #[path = "emcc.rs"]
         mod real_imp;
-    } else if #[cfg(any(target_arch = "wasm32", target_os = "none"))] {
-        #[path = "dummy.rs"]
-        mod real_imp;
     } else if #[cfg(target_os = "hermit")] {
         #[path = "hermit.rs"]
         mod real_imp;
     } else if #[cfg(target_env = "msvc")] {
         #[path = "seh.rs"]
         mod real_imp;
-    } else {
+    } else if #[cfg(any(
+        all(target_family = "windows", target_env = "gnu"),
+        target_os = "cloudabi",
+        target_family = "unix",
+        all(target_vendor = "fortanix", target_env = "sgx"),
+    ))] {
         // Rust runtime's startup objects depend on these symbols, so make them public.
         #[cfg(all(target_os="windows", target_arch = "x86", target_env="gnu"))]
         pub use real_imp::eh_frame_registry::*;
         #[path = "gcc.rs"]
         mod real_imp;
+    } else {
+        // Targets that don't support unwinding.
+        // - arch=wasm32
+        // - os=none ("bare metal" targets)
+        // - os=uefi
+        // - nvptx64-nvidia-cuda
+        // - avr-unknown-unknown
+        // - mipsel-sony-psp
+        #[path = "dummy.rs"]
+        mod real_imp;
     }
 }
 
diff --git a/src/libstd/build.rs b/src/libstd/build.rs
index 8317eedd53f..eb2753d6245 100644
--- a/src/libstd/build.rs
+++ b/src/libstd/build.rs
@@ -62,9 +62,29 @@ fn main() {
         }
         println!("cargo:rustc-link-lib=c");
         println!("cargo:rustc-link-lib=compiler_rt");
-    }
-    println!("cargo:rustc-env=STD_ENV_ARCH={}", env::var("CARGO_CFG_TARGET_ARCH").unwrap());
-    if target.contains("-none") || target.contains("nvptx") {
+    } else if (target.contains("sgx") && target.contains("fortanix"))
+        || target.contains("hermit")
+        || target.contains("l4re")
+        || target.contains("redox")
+        || target.contains("haiku")
+        || target.contains("vxworks")
+        || target.contains("wasm32")
+        || target.contains("asmjs")
+    {
+        // These platforms don't have any special requirements.
+    } else {
+        // This is for Cargo's build-std support, to mark std as unstable for
+        // typically no_std platforms.
+        // This covers:
+        // - os=none ("bare metal" targets)
+        // - mipsel-sony-psp
+        // - nvptx64-nvidia-cuda
+        // - avr-unknown-unknown
+        // - tvos (aarch64-apple-tvos, x86_64-apple-tvos)
+        // - uefi (x86_64-unknown-uefi, i686-unknown-uefi)
+        // - JSON targets
+        // - Any new targets that have not been explicitly added above.
         println!("cargo:rustc-cfg=feature=\"restricted-std\"");
     }
+    println!("cargo:rustc-env=STD_ENV_ARCH={}", env::var("CARGO_CFG_TARGET_ARCH").unwrap());
 }
diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
index c705ed31fd5..c4d10ab177b 100644
--- a/src/libunwind/lib.rs
+++ b/src/libunwind/lib.rs
@@ -9,21 +9,31 @@
 
 cfg_if::cfg_if! {
     if #[cfg(target_env = "msvc")] {
-        // no extra unwinder support needed
-    } else if #[cfg(
-        any(
-            all(target_arch = "wasm32", not(target_os = "emscripten")),
-            target_os = "none",
-            target_os = "hermit",
-            target_os = "uefi",
-            target_os = "cuda",
-            target_os = "l4re",
-        ))]
-    {
-        // no unwinder on the system!
-    } else {
+        // Windows MSVC no extra unwinder support needed
+    } else if #[cfg(any(
+        target_os = "l4re",
+        target_os = "none",
+    ))] {
+        // These "unix" family members do not have unwinder.
+        // Note this also matches x86_64-linux-kernel.
+    } else if #[cfg(any(
+        unix,
+        windows,
+        target_os = "cloudabi",
+        all(target_vendor = "fortanix", target_env = "sgx"),
+    ))] {
         mod libunwind;
         pub use libunwind::*;
+    } else {
+        // no unwinder on the system!
+        // - wasm32 (not emscripten, which is "unix" family)
+        // - os=none ("bare metal" targets)
+        // - os=hermit
+        // - os=uefi
+        // - os=cuda
+        // - nvptx64-nvidia-cuda
+        // - mipsel-sony-psp
+        // - Any new targets not listed above.
     }
 }