]> git.proxmox.com Git - rustc.git/blame - library/unwind/src/lib.rs
New upstream version 1.62.1+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 4#![feature(native_link_modifiers_bundle)]
0bf4aa26 5#![feature(nll)]
a7813a04 6#![feature(staged_api)]
94222f64 7#![feature(c_unwind)]
04454e1e 8#![feature(cfg_target_abi)]
a7813a04 9#![cfg_attr(not(target_env = "msvc"), feature(libc))]
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.
6a06907d 20 // Note this also matches x86_64-unknown-none-linuxkernel.
3dfed10e
XL
21 } else if #[cfg(any(
22 unix,
23 windows,
24 target_os = "psp",
c295e0f8 25 target_os = "solid_asp3",
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",
c295e0f8 65 any(target_env = "gnu", target_env = "uclibc"),
29967ef6
XL
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",
c295e0f8 74 any(target_env = "gnu", target_env = "uclibc"),
29967ef6
XL
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" {}
04454e1e
FG
89
90#[cfg(all(target_os = "windows", target_env = "gnu", target_abi = "llvm"))]
91#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
92extern "C" {}