Skip to content

Commit

Permalink
Add support for wasm exception handling to Emscripten target
Browse files Browse the repository at this point in the history
Gated behind an unstable `-Z emscripten-wasm-eh` flag
  • Loading branch information
hoodmane authored and gitbot committed Feb 20, 2025
1 parent a4abafe commit 367da05
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion panic_unwind/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ libc = { version = "0.2", default-features = false }

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = []
check-cfg = ['cfg(emscripten_wasm_eh)']
3 changes: 2 additions & 1 deletion panic_unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
// `real_imp` is unused with Miri, so silence warnings.
#![cfg_attr(miri, allow(dead_code))]
#![allow(internal_features)]
#![cfg_attr(not(bootstrap), feature(cfg_emscripten_wasm_eh))]

use alloc::boxed::Box;
use core::any::Any;
use core::panic::PanicPayload;

cfg_if::cfg_if! {
if #[cfg(target_os = "emscripten")] {
if #[cfg(all(target_os = "emscripten", not(emscripten_wasm_eh)))] {
#[path = "emcc.rs"]
mod imp;
} else if #[cfg(target_os = "hermit")] {
Expand Down
2 changes: 1 addition & 1 deletion unwind/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ system-llvm-libunwind = []

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = []
check-cfg = ['cfg(emscripten_wasm_eh)']
3 changes: 2 additions & 1 deletion unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#![feature(staged_api)]
#![cfg_attr(not(target_env = "msvc"), feature(libc))]
#![cfg_attr(
all(target_family = "wasm", not(target_os = "emscripten")),
all(target_family = "wasm", any(not(target_os = "emscripten"), emscripten_wasm_eh)),
feature(simd_wasm64, wasm_exception_handling_intrinsics)
)]
#![allow(internal_features)]
#![cfg_attr(not(bootstrap), feature(cfg_emscripten_wasm_eh))]

// Force libc to be included even if unused. This is required by many platforms.
#[cfg(not(all(windows, target_env = "msvc")))]
Expand Down

0 comments on commit 367da05

Please sign in to comment.