std/sys/personality/mod.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
13mod dwarf;
14
15#[cfg(not(any(test, doctest)))]
16cfg_select! {
17 target_os = "emscripten" => {
18 mod emcc;
19 }
20 any(target_env = "msvc", target_family = "wasm") => {
21 // This is required by the compiler to exist (e.g., it's a lang item),
22 // but it's never actually called by the compiler because
23 // __CxxFrameHandler3 (msvc) / __gxx_wasm_personality_v0 (wasm) is the
24 // personality function that is always used. Hence this is just an
25 // aborting stub.
26 #[lang = "eh_personality"]
27 fn rust_eh_personality() {
28 core::intrinsics::abort()
29 }
30 }
31 any(
32 all(target_family = "windows", target_env = "gnu"),
33 target_os = "psp",
34 target_os = "xous",
35 target_os = "solid_asp3",
36 all(
37 target_family = "unix",
38 not(target_os = "espidf"),
39 not(target_os = "l4re"),
40 not(target_os = "nuttx"),
41 // ferrocene addition
42 not(ferrocene_facade_secretsauce),
43 ),
44 all(target_vendor = "fortanix", target_env = "sgx"),
45 ) => {
46 mod gcc;
47 }
48 _ => {
49 // Targets that don't support unwinding.
50 // - os=none ("bare metal" targets)
51 // - os=uefi
52 // - os=espidf
53 // - os=hermit
54 // - nvptx64-nvidia-cuda
55 // - arch=avr
56 }
57}