Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #122031

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
313eb8f
Implement MaybeUninit::fill{,_with,_from}
ajwock Feb 18, 2024
3908a93
std support for wasm32 panic=unwind
coolreader18 Feb 21, 2024
861c7e7
Fix llvm hang
coolreader18 Feb 22, 2024
658a0a2
Unconditionally pass -wasm-enable-eh
coolreader18 Feb 22, 2024
125b26a
Use Itanium ABI for thrown exceptions
coolreader18 Feb 22, 2024
c7fcf43
Don't codegen wasm.throw unless with -Zbuild-std
coolreader18 Feb 26, 2024
a5245ef
Hint user to update nightly on ICEs produced from outdated nightly
jieyouxu Feb 27, 2024
a0ca9b1
Don't suggest update nightly if using internal features
jieyouxu Feb 27, 2024
9c963fc
Adjust wording
jieyouxu Feb 27, 2024
a9a9798
Removing absolute path in proc-macro
sundeep-kokkonda Mar 4, 2024
6e9f59f
add test for #78894
surechen Mar 4, 2024
4e03c51
hir_analysis: enums return `None` in `find_field`
davidtwco Mar 4, 2024
640e99c
Fix duplicated path in the "not found dylib" error
GuillaumeGomez Mar 4, 2024
5e6e140
Add regression ui test for duplicated path in dylib error
GuillaumeGomez Mar 4, 2024
523ab25
add test for #71450
surechen Mar 4, 2024
960dd38
will_wake tests fail on Miri and that is expected
RalfJung Mar 5, 2024
f391c07
only set noalias on Box with the global allocator
RalfJung Mar 5, 2024
da35734
Merge `impl_trait_in_assoc_types_defined_by` query back into `opaque_…
oli-obk Mar 4, 2024
955a160
Rollup merge of #121280 - ajwock:maybeuninit_fill, r=Amanieu
matthiaskrgr Mar 5, 2024
73ab3c7
Rollup merge of #121438 - coolreader18:wasm32-panic-unwind, r=cuviper
matthiaskrgr Mar 5, 2024
e788f15
Rollup merge of #121658 - jieyouxu:ice-outdated-nightly, r=oli-obk
matthiaskrgr Mar 5, 2024
5b4f049
Rollup merge of #121959 - sundeep-kokkonda:patch-2, r=davidtwco
matthiaskrgr Mar 5, 2024
8676983
Rollup merge of #121961 - surechen:add_test_20240304, r=petrochenkov
matthiaskrgr Mar 5, 2024
b7a60d8
Rollup merge of #121975 - davidtwco:issue-121757, r=petrochenkov
matthiaskrgr Mar 5, 2024
d08dcea
Rollup merge of #121978 - GuillaumeGomez:dylib-duplicated-path, r=bjorn3
matthiaskrgr Mar 5, 2024
9e3f983
Rollup merge of #121991 - oli-obk:merge_opaque_types_defined_by_queri…
matthiaskrgr Mar 5, 2024
62aed06
Rollup merge of #122016 - RalfJung:will_wake, r=dtolnay
matthiaskrgr Mar 5, 2024
8834019
Rollup merge of #122018 - RalfJung:box-custom-alloc, r=oli-obk
matthiaskrgr Mar 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use Itanium ABI for thrown exceptions
  • Loading branch information
coolreader18 committed Feb 22, 2024
commit 125b26acf6f3127ecdd344c372691cefe0e9243e
2 changes: 1 addition & 1 deletion library/panic_unwind/src/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
let exception = Box::new(Exception {
_uwe: uw::_Unwind_Exception {
exception_class: rust_exception_class(),
exception_cleanup,
exception_cleanup: Some(exception_cleanup),
private: [core::ptr::null(); uw::unwinder_private_data_size],
},
canary: &CANARY,
Expand Down
8 changes: 1 addition & 7 deletions library/panic_unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
#![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
#![feature(core_intrinsics)]
#![feature(lang_items)]
#![cfg_attr(
all(target_family = "wasm", not(target_os = "emscripten")),
feature(link_llvm_intrinsics)
)]
#![feature(panic_unwind)]
#![feature(staged_api)]
#![feature(std_internals)]
Expand Down Expand Up @@ -57,12 +53,10 @@ cfg_if::cfg_if! {
target_os = "solid_asp3",
all(target_family = "unix", not(target_os = "espidf")),
all(target_vendor = "fortanix", target_env = "sgx"),
target_family = "wasm",
))] {
#[path = "gcc.rs"]
mod real_imp;
} else if #[cfg(target_family = "wasm")] {
#[path = "wasm.rs"]
mod real_imp;
} else {
// Targets that don't support unwinding.
// - os=none ("bare metal" targets)
Expand Down
32 changes: 0 additions & 32 deletions library/panic_unwind/src/wasm.rs

This file was deleted.

8 changes: 7 additions & 1 deletion library/unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#![feature(cfg_target_abi)]
#![feature(strict_provenance)]
#![cfg_attr(not(target_env = "msvc"), feature(libc))]
#![cfg_attr(
all(target_family = "wasm", not(target_os = "emscripten")),
feature(link_llvm_intrinsics)
)]
#![allow(internal_features)]

cfg_if::cfg_if! {
Expand All @@ -29,9 +33,11 @@ cfg_if::cfg_if! {
} else if #[cfg(target_os = "xous")] {
mod unwinding;
pub use unwinding::*;
} else if #[cfg(target_family = "wasm")] {
mod wasm;
pub use wasm::*;
} else {
// no unwinder on the system!
// - wasm32 (not emscripten, which is "unix" family)
// - os=none ("bare metal" targets)
// - os=hermit
// - os=uefi
Expand Down
2 changes: 1 addition & 1 deletion library/unwind/src/libunwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub struct _Unwind_Exception {
pub enum _Unwind_Context {}

pub type _Unwind_Exception_Cleanup_Fn =
extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception);
Option<extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception)>;

// FIXME: The `#[link]` attributes on `extern "C"` block marks those symbols declared in
// the block are reexported in dylib build of std. This is needed when build rustc with
Expand Down
2 changes: 1 addition & 1 deletion library/unwind/src/unwinding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub const unwinder_private_data_size: usize = core::mem::size_of::<UnwindExcepti
- core::mem::size_of::<_Unwind_Exception_Cleanup_Fn>();

pub type _Unwind_Exception_Cleanup_Fn =
extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception);
Option<extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception)>;

#[repr(C)]
pub struct _Unwind_Exception {
Expand Down
56 changes: 56 additions & 0 deletions library/unwind/src/wasm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//! A shim for libunwind implemented in terms of the native wasm `throw` instruction.

#![allow(nonstandard_style)]

#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum _Unwind_Reason_Code {
_URC_NO_REASON = 0,
_URC_FOREIGN_EXCEPTION_CAUGHT = 1,
_URC_FATAL_PHASE2_ERROR = 2,
_URC_FATAL_PHASE1_ERROR = 3,
_URC_NORMAL_STOP = 4,
_URC_END_OF_STACK = 5,
_URC_HANDLER_FOUND = 6,
_URC_INSTALL_CONTEXT = 7,
_URC_CONTINUE_UNWIND = 8,
_URC_FAILURE = 9, // used only by ARM EHABI
}
pub use _Unwind_Reason_Code::*;

pub type _Unwind_Exception_Class = u64;
pub type _Unwind_Word = *const u8;

pub const unwinder_private_data_size: usize = 2;

#[repr(C)]
pub struct _Unwind_Exception {
pub exception_class: _Unwind_Exception_Class,
pub exception_cleanup: _Unwind_Exception_Cleanup_Fn,
pub private: [_Unwind_Word; unwinder_private_data_size],
}

pub type _Unwind_Exception_Cleanup_Fn =
Option<extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception)>;

pub unsafe fn _Unwind_DeleteException(exception: *mut _Unwind_Exception) {
if let Some(exception_cleanup) = unsafe { (*exception).exception_cleanup } {
exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, exception);
}
}

pub unsafe fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code {
extern "C" {
/// LLVM lowers this intrinsic to the `throw` instruction.
// FIXME(coolreader18): move to stdarch
#[link_name = "llvm.wasm.throw"]
fn wasm_throw(tag: i32, ptr: *mut u8) -> !;
}

// The wasm `throw` instruction takes a "tag", which differentiates certain
// types of exceptions from others. LLVM currently just identifies these
// via integers, with 0 corresponding to C++ exceptions and 1 to C setjmp()/longjmp().
// Ideally, we'd be able to choose something unique for Rust, but for now,
// we pretend to be C++ and implement the Itanium exception-handling ABI.
wasm_throw(0, exception.cast())
}
Loading