]> git.proxmox.com Git - rustc.git/blame - library/unwind/src/lib.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / library / unwind / src / lib.rs
CommitLineData
a7813a04 1#![no_std]
a7813a04 2#![unstable(feature = "panic_unwind", issue = "32837")]
3b2f2976 3#![feature(link_cfg)]
94222f64
XL
4#![feature(native_link_modifiers)]
5#![feature(native_link_modifiers_bundle)]
0bf4aa26 6#![feature(nll)]
a7813a04 7#![feature(staged_api)]
cc61c64b 8#![feature(static_nobundle)]
94222f64 9#![feature(c_unwind)]
a7813a04 10#![cfg_attr(not(target_env = "msvc"), feature(libc))]
7453a54e 11
dc9dc135 12cfg_if::cfg_if! {
abe05a73 13 if #[cfg(target_env = "msvc")] {
3dfed10e
XL
14 // Windows MSVC no extra unwinder support needed
15 } else if #[cfg(any(
16 target_os = "l4re",
17 target_os = "none",
94222f64 18 target_os = "espidf",
3dfed10e
XL
19 ))] {
20 // These "unix" family members do not have unwinder.
6a06907d 21 // Note this also matches x86_64-unknown-none-linuxkernel.
3dfed10e
XL
22 } else if #[cfg(any(
23 unix,
24 windows,
25 target_os = "psp",
3dfed10e
XL
26 all(target_vendor = "fortanix", target_env = "sgx"),
27 ))] {
abe05a73
XL
28 mod libunwind;
29 pub use libunwind::*;
3dfed10e
XL
30 } else {
31 // no unwinder on the system!
32 // - wasm32 (not emscripten, which is "unix" family)
33 // - os=none ("bare metal" targets)
34 // - os=hermit
35 // - os=uefi
36 // - os=cuda
37 // - nvptx64-nvidia-cuda
38 // - Any new targets not listed above.
abe05a73
XL
39 }
40}
3b2f2976 41
2c00a5a8 42#[cfg(target_env = "musl")]
17df50a5
XL
43cfg_if::cfg_if! {
44 if #[cfg(all(feature = "llvm-libunwind", feature = "system-llvm-libunwind"))] {
45 compile_error!("`llvm-libunwind` and `system-llvm-libunwind` cannot be enabled at the same time");
46 } else if #[cfg(feature = "llvm-libunwind")] {
94222f64 47 #[link(name = "unwind", kind = "static", modifiers = "-bundle")]
17df50a5
XL
48 extern "C" {}
49 } else if #[cfg(feature = "system-llvm-libunwind")] {
94222f64 50 #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
17df50a5
XL
51 #[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
52 extern "C" {}
53 } else {
94222f64 54 #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
17df50a5
XL
55 #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
56 extern "C" {}
57 }
58}
416331ca 59
29967ef6
XL
60// When building with crt-static, we get `gcc_eh` from the `libc` crate, since
61// glibc needs it, and needs it listed later on the linker command line. We
62// don't want to duplicate it here.
63#[cfg(all(
64 target_os = "linux",
65 target_env = "gnu",
66 not(feature = "llvm-libunwind"),
67 not(feature = "system-llvm-libunwind")
68))]
69#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
70extern "C" {}
71
72#[cfg(all(
73 target_os = "linux",
74 target_env = "gnu",
75 not(feature = "llvm-libunwind"),
76 feature = "system-llvm-libunwind"
77))]
78#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
79extern "C" {}
80
416331ca 81#[cfg(target_os = "redox")]
94222f64 82#[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
416331ca 83#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
dfeec247 84extern "C" {}
f9f354fc
XL
85
86#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
94222f64 87#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
f9f354fc 88extern "C" {}