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