-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
These were previously in the panic_unwind crate with dummy stubs in the panic_abort crate. However it turns out that this is insufficient: we still need a proper personality function even with -C panic=abort to handle the following cases: 1) `extern "C-unwind"` still needs to catch foreign exceptions with -C panic=abort to turn them into aborts. This requires landing pads and a personality function. 2) ARM EHABI uses the personality function when creating backtraces. The dummy personality function in panic_abort was causing backtrace generation to get stuck in a loop since the personality function is responsible for advancing the unwind state to the next frame.
- Loading branch information
Showing
12 changed files
with
347 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//! This module contains the implementation of the `eh_personality` lang item. | ||
//! | ||
//! The actual implementation is heavily dependent on the target since Rust | ||
//! tries to use the native stack unwinding mechanism whenever possible. | ||
//! | ||
//! This personality function is still required with `-C panic=abort` because | ||
//! it is used to catch foreign exceptions from `extern "C-unwind"` and turn | ||
//! them into aborts. | ||
//! | ||
//! Additionally, ARM EHABI uses the personality function when generating | ||
//! backtraces. | ||
mod dwarf; | ||
|
||
#[cfg(not(test))] | ||
cfg_if::cfg_if! { | ||
if #[cfg(target_os = "emscripten")] { | ||
mod emcc; | ||
} else if #[cfg(target_env = "msvc")] { | ||
// This is required by the compiler to exist (e.g., it's a lang item), | ||
// but it's never actually called by the compiler because | ||
// _CxxFrameHandler3 is the personality function that is always used. | ||
// Hence this is just an aborting stub. | ||
#[lang = "eh_personality"] | ||
fn rust_eh_personality() { | ||
core::intrinsics::abort() | ||
} | ||
} else if #[cfg(any( | ||
all(target_family = "windows", target_env = "gnu"), | ||
target_os = "psp", | ||
target_os = "solid_asp3", | ||
all(target_family = "unix", not(target_os = "espidf")), | ||
all(target_vendor = "fortanix", target_env = "sgx"), | ||
))] { | ||
mod gcc; | ||
} else { | ||
// Targets that don't support unwinding. | ||
// - family=wasm | ||
// - os=none ("bare metal" targets) | ||
// - os=uefi | ||
// - os=espidf | ||
// - os=hermit | ||
// - nvptx64-nvidia-cuda | ||
// - arch=avr | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.