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

Add support for wasm exception handling to Emscripten target #131830

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ unsafe fn configure_llvm(sess: &Session) {
add("-wasm-enable-eh", false);
}

if sess.target.os == "emscripten" && sess.panic_strategy() == PanicStrategy::Unwind {
add("-enable-emscripten-cxx-exceptions", false);
}
// if sess.target.os == "emscripten" && sess.panic_strategy() == PanicStrategy::Unwind {
// add("-enable-emscripten-cxx-exceptions", false);
// }

// HACK(eddyb) LLVM inserts `llvm.assume` calls to preserve align attributes
// during inlining. Unfortunately these may block other optimizations.
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2437,10 +2437,10 @@ fn add_order_independent_options(
}

if sess.target.os == "emscripten" {
cmd.cc_arg("-s").cc_arg(if sess.panic_strategy() == PanicStrategy::Abort {
"DISABLE_EXCEPTION_CATCHING=1"
cmd.cc_arg(if sess.panic_strategy() == PanicStrategy::Abort {
"-sDISABLE_EXCEPTION_CATCHING=1"
} else {
"DISABLE_EXCEPTION_CATCHING=0"
"-fwasm-exceptions"
});
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ pub(crate) fn build_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
// exceptions. This means that the VM does the unwinding for
// us
pub fn wants_wasm_eh(sess: &Session) -> bool {
sess.target.is_like_wasm && sess.target.os != "emscripten"
sess.target.is_like_wasm
}

/// Returns `true` if this session's target will use SEH-based unwinding.
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_passes/src/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pub(crate) fn check_crate(
if items.eh_personality().is_none() {
items.missing.push(LangItem::EhPersonality);
}
if tcx.sess.target.os == "emscripten" && items.eh_catch_typeinfo().is_none() {
items.missing.push(LangItem::EhCatchTypeinfo);
}
// if tcx.sess.target.os == "emscripten" && items.eh_catch_typeinfo().is_none() {
// items.missing.push(LangItem::EhCatchTypeinfo);
// }

visit::Visitor::visit_crate(&mut WeakLangItemVisitor { tcx, items }, krate);

Expand Down
5 changes: 1 addition & 4 deletions library/panic_unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ use core::any::Any;
use core::panic::PanicPayload;

cfg_if::cfg_if! {
if #[cfg(target_os = "emscripten")] {
#[path = "emcc.rs"]
mod imp;
} else if #[cfg(target_os = "hermit")] {
if #[cfg(target_os = "hermit")] {
#[path = "hermit.rs"]
mod imp;
} else if #[cfg(target_os = "l4re")] {
Expand Down
5 changes: 1 addition & 4 deletions library/unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
#![feature(staged_api)]
#![feature(strict_provenance)]
#![cfg_attr(not(target_env = "msvc"), feature(libc))]
#![cfg_attr(
all(target_family = "wasm", not(target_os = "emscripten")),
feature(simd_wasm64, wasm_exception_handling_intrinsics)
)]
#![cfg_attr(all(target_family = "wasm"), feature(simd_wasm64, wasm_exception_handling_intrinsics))]
#![allow(internal_features)]

// Force libc to be included even if unused. This is required by many platforms.
Expand Down
Loading