]> git.proxmox.com Git - rustc.git/blame - library/unwind/src/lib.rs
bump version to 1.75.0+dfsg1-1~bpo12+pve1
[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)]
a7813a04 4#![feature(staged_api)]
94222f64 5#![feature(c_unwind)]
04454e1e 6#![feature(cfg_target_abi)]
ed00b5ec 7#![feature(strict_provenance)]
a7813a04 8#![cfg_attr(not(target_env = "msvc"), feature(libc))]
781aab86 9#![allow(internal_features)]
7453a54e 10
dc9dc135 11cfg_if::cfg_if! {
abe05a73 12 if #[cfg(target_env = "msvc")] {
3dfed10e
XL
13 // Windows MSVC no extra unwinder support needed
14 } else if #[cfg(any(
15 target_os = "l4re",
16 target_os = "none",
94222f64 17 target_os = "espidf",
3dfed10e
XL
18 ))] {
19 // These "unix" family members do not have unwinder.
3dfed10e
XL
20 } else if #[cfg(any(
21 unix,
22 windows,
23 target_os = "psp",
c295e0f8 24 target_os = "solid_asp3",
3dfed10e
XL
25 all(target_vendor = "fortanix", target_env = "sgx"),
26 ))] {
abe05a73
XL
27 mod libunwind;
28 pub use libunwind::*;
3dfed10e
XL
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.
abe05a73
XL
38 }
39}
3b2f2976 40
2c00a5a8 41#[cfg(target_env = "musl")]
17df50a5
XL
42cfg_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")] {
94222f64 46 #[link(name = "unwind", kind = "static", modifiers = "-bundle")]
17df50a5
XL
47 extern "C" {}
48 } else if #[cfg(feature = "system-llvm-libunwind")] {
94222f64 49 #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
17df50a5
XL
50 #[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
51 extern "C" {}
52 } else {
94222f64 53 #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
17df50a5
XL
54 #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
55 extern "C" {}
56 }
57}
416331ca 58
353b0b11
FG
59// This is the same as musl except that we default to using the system libunwind
60// instead of libgcc.
61#[cfg(target_env = "ohos")]
62cfg_if::cfg_if! {
63 if #[cfg(all(feature = "llvm-libunwind", feature = "system-llvm-libunwind"))] {
64 compile_error!("`llvm-libunwind` and `system-llvm-libunwind` cannot be enabled at the same time");
65 } else if #[cfg(feature = "llvm-libunwind")] {
66 #[link(name = "unwind", kind = "static", modifiers = "-bundle")]
67 extern "C" {}
68 } else {
69 #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
70 #[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
71 extern "C" {}
72 }
73}
74
f2b60f7d
FG
75#[cfg(target_os = "android")]
76cfg_if::cfg_if! {
77 if #[cfg(feature = "llvm-libunwind")] {
78 compile_error!("`llvm-libunwind` is not supported for Android targets");
ed00b5ec 79 } else {
f2b60f7d
FG
80 #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
81 #[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
82 extern "C" {}
f2b60f7d
FG
83 }
84}
85// Android's unwinding library depends on dl_iterate_phdr in `libdl`.
86#[cfg(target_os = "android")]
87#[link(name = "dl", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
88#[link(name = "dl", cfg(not(target_feature = "crt-static")))]
89extern "C" {}
90
29967ef6
XL
91// When building with crt-static, we get `gcc_eh` from the `libc` crate, since
92// glibc needs it, and needs it listed later on the linker command line. We
93// don't want to duplicate it here.
94#[cfg(all(
95 target_os = "linux",
c295e0f8 96 any(target_env = "gnu", target_env = "uclibc"),
29967ef6
XL
97 not(feature = "llvm-libunwind"),
98 not(feature = "system-llvm-libunwind")
99))]
100#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
101extern "C" {}
102
103#[cfg(all(
104 target_os = "linux",
c295e0f8 105 any(target_env = "gnu", target_env = "uclibc"),
29967ef6
XL
106 not(feature = "llvm-libunwind"),
107 feature = "system-llvm-libunwind"
108))]
109#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
110extern "C" {}
111
416331ca 112#[cfg(target_os = "redox")]
94222f64 113#[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
416331ca 114#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
dfeec247 115extern "C" {}
f9f354fc
XL
116
117#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
94222f64 118#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
f9f354fc 119extern "C" {}
04454e1e 120
487cf647
FG
121#[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
122#[link(name = "gcc_s")]
123extern "C" {}
124
125#[cfg(all(target_os = "openbsd", target_arch = "sparc64"))]
126#[link(name = "gcc")]
127extern "C" {}
128
129#[cfg(all(target_os = "openbsd", not(target_arch = "sparc64")))]
130#[link(name = "c++abi")]
131extern "C" {}
132
133#[cfg(any(target_os = "solaris", target_os = "illumos"))]
134#[link(name = "gcc_s")]
135extern "C" {}
136
137#[cfg(target_os = "dragonfly")]
138#[link(name = "gcc_pic")]
139extern "C" {}
140
141#[cfg(target_os = "haiku")]
142#[link(name = "gcc_s")]
04454e1e 143extern "C" {}
9ffffee4 144
ed00b5ec
FG
145#[cfg(target_os = "aix")]
146#[link(name = "unwind")]
147extern "C" {}
148
9ffffee4
FG
149#[cfg(target_os = "nto")]
150#[link(name = "gcc_s")]
151extern "C" {}
781aab86
FG
152
153#[cfg(target_os = "hurd")]
154#[link(name = "gcc_s")]
155extern "C" {}