]> git.lizzy.rs Git - rust.git/blob - library/unwind/src/lib.rs
Rollup merge of #93217 - willcrichton:example-analyzer, r=GuillaumeGomez
[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_bundle)]
5 #![feature(nll)]
6 #![feature(staged_api)]
7 #![feature(c_unwind)]
8 #![cfg_attr(not(target_env = "msvc"), feature(libc))]
9
10 cfg_if::cfg_if! {
11     if #[cfg(target_env = "msvc")] {
12         // Windows MSVC no extra unwinder support needed
13     } else if #[cfg(any(
14         target_os = "l4re",
15         target_os = "none",
16         target_os = "espidf",
17     ))] {
18         // These "unix" family members do not have unwinder.
19         // Note this also matches x86_64-unknown-none-linuxkernel.
20     } else if #[cfg(any(
21         unix,
22         windows,
23         target_os = "psp",
24         target_os = "solid_asp3",
25         all(target_vendor = "fortanix", target_env = "sgx"),
26     ))] {
27         mod libunwind;
28         pub use libunwind::*;
29     } else {
30         // no unwinder on the system!
31         // - wasm32 (not emscripten, which is "unix" family)
32         // - os=none ("bare metal" targets)
33         // - os=hermit
34         // - os=uefi
35         // - os=cuda
36         // - nvptx64-nvidia-cuda
37         // - Any new targets not listed above.
38     }
39 }
40
41 #[cfg(target_env = "musl")]
42 cfg_if::cfg_if! {
43     if #[cfg(all(feature = "llvm-libunwind", feature = "system-llvm-libunwind"))] {
44         compile_error!("`llvm-libunwind` and `system-llvm-libunwind` cannot be enabled at the same time");
45     } else if #[cfg(feature = "llvm-libunwind")] {
46         #[link(name = "unwind", kind = "static", modifiers = "-bundle")]
47         extern "C" {}
48     } else if #[cfg(feature = "system-llvm-libunwind")] {
49         #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
50         #[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
51         extern "C" {}
52     } else {
53         #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
54         #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
55         extern "C" {}
56     }
57 }
58
59 // When building with crt-static, we get `gcc_eh` from the `libc` crate, since
60 // glibc needs it, and needs it listed later on the linker command line. We
61 // don't want to duplicate it here.
62 #[cfg(all(
63     target_os = "linux",
64     any(target_env = "gnu", target_env = "uclibc"),
65     not(feature = "llvm-libunwind"),
66     not(feature = "system-llvm-libunwind")
67 ))]
68 #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
69 extern "C" {}
70
71 #[cfg(all(
72     target_os = "linux",
73     any(target_env = "gnu", target_env = "uclibc"),
74     not(feature = "llvm-libunwind"),
75     feature = "system-llvm-libunwind"
76 ))]
77 #[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
78 extern "C" {}
79
80 #[cfg(target_os = "redox")]
81 #[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
82 #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
83 extern "C" {}
84
85 #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
86 #[link(name = "unwind", kind = "static", modifiers = "-bundle")]
87 extern "C" {}