Use an allow-list of platforms that support std.
Use a fall-through for no_std targets.
This commit is contained in:
parent
cee9f05c2d
commit
0eb293ddb7
@ -41,21 +41,33 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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.
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user