Skip to content

Commit a25a35d

Browse files
committed
Unrolled build for #160440
Rollup merge of #160440 - bjorn3:refactor_unwind4, r=Mark-Simulacrum Couple of misc improvements to the unwind infrastructure * Fix `_Unwind_Exception` size on Emscripten. * Move a link block. * Remove some manual dummy impls where there is already a dummy fallback. Follow up to #159785
2 parents 93c9086 + 37831ee commit a25a35d

7 files changed

Lines changed: 16 additions & 36 deletions

File tree

library/panic_unwind/src/dummy.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
55
use alloc::boxed::Box;
66
use core::any::Any;
7-
use core::intrinsics;
7+
8+
unsafe extern "Rust" {
9+
// This is defined in std::rt
10+
#[rustc_std_internal_symbol]
11+
safe fn __rust_abort() -> !;
12+
}
813

914
pub(crate) unsafe fn cleanup(_ptr: *mut u8) -> Box<dyn Any + Send> {
10-
intrinsics::abort()
15+
__rust_abort()
1116
}
1217

1318
pub(crate) unsafe fn panic(_data: Box<dyn Any + Send>) -> u32 {
14-
intrinsics::abort()
19+
__rust_abort()
1520
}

library/panic_unwind/src/hermit.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

library/panic_unwind/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ use core::any::Any;
3232
use core::panic::PanicPayload;
3333

3434
cfg_select! {
35-
target_os = "hermit" => {
36-
#[path = "hermit.rs"]
37-
mod imp;
38-
}
3935
any(
4036
all(target_family = "windows", target_env = "gnu"),
4137
target_os = "psp",
@@ -64,6 +60,7 @@ cfg_select! {
6460
// - os=none ("bare metal" targets)
6561
// - os=uefi
6662
// - os=espidf
63+
// - os=hermit
6764
// - nvptx64-nvidia-cuda
6865
// - arch=avr
6966
#[path = "dummy.rs"]

library/std/src/sys/personality/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod dwarf;
1414

1515
#[cfg(not(any(test, doctest)))]
1616
cfg_select! {
17-
any(target_env = "msvc", target_family = "wasm", target_os = "motor") => {
17+
any(target_env = "msvc", target_family = "wasm") => {
1818
// This is required by the compiler to exist (e.g., it's a lang item),
1919
// but it's never actually called by the compiler because
2020
// __CxxFrameHandler3 (msvc) / __gxx_wasm_personality_v0 (wasm) is the
@@ -41,6 +41,7 @@ cfg_select! {
4141
// - os=uefi
4242
// - os=espidf
4343
// - os=hermit
44+
// - os=motor
4445
// - nvptx64-nvidia-cuda
4546
// - arch=avr
4647
}

library/unwind/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ cfg_select! {
4848
// no unwinder on the system!
4949
// - os=none ("bare metal" targets)
5050
// - os=hermit
51+
// - os=motor
5152
// - os=uefi
5253
// - os=cuda
5354
// - nvptx64-nvidia-cuda
@@ -215,6 +216,10 @@ cfg_select! {
215216
#[link(name = "gcc_s")]
216217
unsafe extern "C" {}
217218

219+
#[cfg(all(target_os = "wasi", panic = "unwind"))]
220+
#[link(name = "unwind")]
221+
unsafe extern "C" {}
222+
218223
#[cfg(all(target_os = "windows", target_env = "gnu", target_abi = "llvm"))]
219224
#[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
220225
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]

library/unwind/src/libunwind.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ pub enum _Unwind_Context {}
2626
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")),
2727
link(name = "unwind", kind = "static", modifiers = "-bundle")
2828
)]
29-
// Explicitly link the `unwind` library on WASI targets.
30-
//
31-
// This is provided in the self-contained sysroot for WASI targets by default.
32-
// Note that Rust defaults to `-Cpanic=abort` on WASI targets meaning that this
33-
// doesn't end up getting used by default, but this does mean that with
34-
// `-Zbuild-std` this'll automatically link it in.
35-
#[cfg_attr(target_os = "wasi", link(name = "unwind"))]
3629
unsafe extern "C-unwind" {
3730
pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !;
3831
}

library/unwind/src/types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ pub const unwinder_private_data_size: usize = cfg_select! {
3636
target_arch = "s390x" => 2,
3737
any(target_arch = "sparc", target_arch = "sparc64") => 2,
3838
any(target_arch = "riscv64", target_arch = "riscv32") => 2,
39-
all(target_family = "wasm", target_os = "emscripten") => 20,
4039
target_family = "wasm" => 2,
4140
target_arch = "hexagon" => 5,
4241
any(target_arch = "loongarch32", target_arch = "loongarch64") => 2,

0 commit comments

Comments
 (0)