Skip to content

Commit

Permalink
Auto merge of #103894 - mati865:gnullvm-libunwind-changes, r=thomcc
Browse files Browse the repository at this point in the history
Change the way libunwind is linked for *-windows-gnullvm targets

I have no idea why previous way works for `x86_64-fortanix-unknown-sgx` (assuming it actually works...) but not for `gnullvm`. It fails when linking libtest during Rust build (unless somebody adds `RUSTFLAGS='-Clinkarg=-lunwind'`).
Also fixes exception handling on AArch64.
  • Loading branch information
bors committed Nov 13, 2022
2 parents ea28fd5 + e066709 commit 6723bf5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion std/src/personality/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ cfg_if::cfg_if! {
}

cfg_if::cfg_if! {
if #[cfg(all(windows, target_arch = "x86_64", target_env = "gnu"))] {
if #[cfg(all(windows, any(target_arch = "aarch64", target_arch = "x86_64"), target_env = "gnu"))] {
// On x86_64 MinGW targets, the unwinding mechanism is SEH however the unwind
// handler data (aka LSDA) uses GCC-compatible encoding.
#[lang = "eh_personality"]
Expand Down
4 changes: 0 additions & 4 deletions unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,3 @@ extern "C" {}
#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
extern "C" {}

#[cfg(all(target_os = "windows", target_env = "gnu", target_abi = "llvm"))]
#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
extern "C" {}
10 changes: 8 additions & 2 deletions unwind/src/libunwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ pub const unwinder_private_data_size: usize = 20;
#[cfg(all(target_arch = "arm", any(target_os = "ios", target_os = "watchos")))]
pub const unwinder_private_data_size: usize = 5;

#[cfg(all(target_arch = "aarch64", target_pointer_width = "64"))]
#[cfg(all(target_arch = "aarch64", target_pointer_width = "64", not(target_os = "windows")))]
pub const unwinder_private_data_size: usize = 2;

#[cfg(all(target_arch = "aarch64", target_pointer_width = "64", target_os = "windows"))]
pub const unwinder_private_data_size: usize = 6;

#[cfg(all(target_arch = "aarch64", target_pointer_width = "32"))]
pub const unwinder_private_data_size: usize = 5;

Expand Down Expand Up @@ -90,7 +93,10 @@ pub type _Unwind_Exception_Cleanup_Fn =
// rustc_codegen_ssa::src::back::symbol_export, rustc_middle::middle::exported_symbols
// and RFC 2841
#[cfg_attr(
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")),
any(
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")),
all(target_os = "windows", target_env = "gnu", target_abi = "llvm")
),
link(name = "unwind", kind = "static", modifiers = "-bundle")
)]
extern "C-unwind" {
Expand Down

0 comments on commit 6723bf5

Please sign in to comment.