Allow ffi_unwind_calls for arch::wasm32::throw

This commit is contained in:
Alisa Sireneva
2025-07-25 15:07:55 +03:00
parent ed11a39643
commit 17519aeaef

View File

@@ -191,6 +191,16 @@ unsafe extern "C-unwind" {
// #[cfg_attr(test, assert_instr(throw, TAG = 0, ptr = core::ptr::null_mut()))] // #[cfg_attr(test, assert_instr(throw, TAG = 0, ptr = core::ptr::null_mut()))]
#[inline] #[inline]
#[unstable(feature = "wasm_exception_handling_intrinsics", issue = "122465")] #[unstable(feature = "wasm_exception_handling_intrinsics", issue = "122465")]
// FIXME: Since this instruction unwinds, `core` built with `-C panic=unwind`
// cannot be linked with `-C panic=abort` programs. But that's not
// entirely supported anyway, because runtimes without EH support won't
// be able to handle `try` blocks in `-C panic=unwind` crates either.
// We ship `-C panic=abort` `core`, so this doesn't affect users
// directly. Resolving this will likely require patching out both `try`
// and `throw` instructions, at which point we can look into whitelisting
// this function in the compiler to allow linking.
// See https://github.com/rust-lang/rust/issues/118168.
#[allow(ffi_unwind_calls)]
pub unsafe fn throw<const TAG: i32>(ptr: *mut u8) -> ! { pub unsafe fn throw<const TAG: i32>(ptr: *mut u8) -> ! {
static_assert!(TAG == 0); // LLVM only supports tag 0 == C++ right now. static_assert!(TAG == 0); // LLVM only supports tag 0 == C++ right now.
wasm_throw(TAG, ptr) wasm_throw(TAG, ptr)