]> git.lizzy.rs Git - rust.git/blob - library/std/src/personality.rs
Auto merge of #103491 - cjgillot:self-rpit, r=oli-obk
[rust.git] / library / std / src / personality.rs
1 //! This module contains the implementation of the `eh_personality` lang item.
2 //!
3 //! The actual implementation is heavily dependent on the target since Rust
4 //! tries to use the native stack unwinding mechanism whenever possible.
5 //!
6 //! This personality function is still required with `-C panic=abort` because
7 //! it is used to catch foreign exceptions from `extern "C-unwind"` and turn
8 //! them into aborts.
9 //!
10 //! Additionally, ARM EHABI uses the personality function when generating
11 //! backtraces.
12
13 mod dwarf;
14
15 #[cfg(not(test))]
16 cfg_if::cfg_if! {
17     if #[cfg(target_os = "emscripten")] {
18         mod emcc;
19     } else if #[cfg(target_env = "msvc")] {
20         // This is required by the compiler to exist (e.g., it's a lang item),
21         // but it's never actually called by the compiler because
22         // _CxxFrameHandler3 is the personality function that is always used.
23         // Hence this is just an aborting stub.
24         #[lang = "eh_personality"]
25         fn rust_eh_personality() {
26             core::intrinsics::abort()
27         }
28     } else if #[cfg(any(
29         all(target_family = "windows", target_env = "gnu"),
30         target_os = "psp",
31         target_os = "solid_asp3",
32         all(target_family = "unix", not(target_os = "espidf")),
33         all(target_vendor = "fortanix", target_env = "sgx"),
34     ))] {
35         mod gcc;
36     } else {
37         // Targets that don't support unwinding.
38         // - family=wasm
39         // - os=none ("bare metal" targets)
40         // - os=uefi
41         // - os=espidf
42         // - os=hermit
43         // - nvptx64-nvidia-cuda
44         // - arch=avr
45     }
46 }