]> git.lizzy.rs Git - rust.git/blob - library/unwind/src/lib.rs
Merge commit '40b00f4200fbdeefd11815398cb46394b8cb0a5e' into sync_cg_clif-2021-12-30
[rust.git] / library / unwind / src / lib.rs
1 #![no_std]
2 #![unstable(feature = "panic_unwind", issue = "32837")]
3 #![feature(link_cfg)]
4 #![feature(native_link_modifiers)]
5 #![feature(native_link_modifiers_bundle)]
6 #![feature(nll)]
7 #![feature(staged_api)]
8 #![feature(c_unwind)]
9 #![cfg_attr(not(target_env = "msvc"), feature(libc))]
10
11 cfg_if::cfg_if! {
12     if #[cfg(target_env = "msvc")] {
13         // Windows MSVC no extra unwinder support needed
14     } else if #[cfg(any(
15         target_os = "l4re",
16         target_os = "none",
17         target_os = "espidf",
18     ))] {
19         // These "unix" family members do not have unwinder.
20         // Note this also matches x86_64-unknown-none-linuxkernel.
21     } else if #[cfg(any(
22         unix,
23         windows,
24         target_os = "psp",
25         target_os = "solid_asp3",
26         all(target_vendor = "fortanix", target_env = "sgx"),
27     ))] {
28         mod libunwind;
29         pub use libunwind::*;
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.
39     }
40 }
41
42 #[cfg(target_env = "musl")]
43 cfg_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")] {
47         #[link(name = "unwind", kind = "static", modifiers = "-bundle")]
48         extern "C" {}
49     } else if #[cfg(feature = "system-llvm-libunwind")] {
50         #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
51         #[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
52         extern "C" {}
53     } else {
54         #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
55         #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
56         extern "C" {}
57     }
58 }
59
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     any(target_env = "gnu", target_env = "uclibc"),
66     not(feature = "llvm-libunwind"),
67     not(feature = "system-llvm-libunwind")
68 ))]
69 #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
70 extern "C" {}
71
72 #[cfg(all(
73     target_os = "linux",
74     any(target_env = "gnu", target_env = "uclibc"),
75     not(feature = "llvm-libunwind"),
76     feature = "system-llvm-libunwind"
77 ))]
78 #[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
79 extern "C" {}
80
81 #[cfg(target_os = "redox")]
82 #[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
83 #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
84 extern "C" {}
85
86 #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
87 #[link(name = "unwind", kind = "static", modifiers = "-bundle")]
88 extern "C" {}