Skip to content

Commit ad37cc8

Browse files
committed
Add support for wasm exception handling to Emscripten target
1 parent bf6f8a4 commit ad37cc8

File tree

6 files changed

+12
-18
lines changed

6 files changed

+12
-18
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ unsafe fn configure_llvm(sess: &Session) {
109109
add("-wasm-enable-eh", false);
110110
}
111111

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

116116
// HACK(eddyb) LLVM inserts `llvm.assume` calls to preserve align attributes
117117
// during inlining. Unfortunately these may block other optimizations.

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,10 +2466,10 @@ fn add_order_independent_options(
24662466
}
24672467

24682468
if sess.target.os == "emscripten" {
2469-
cmd.cc_arg("-s").cc_arg(if sess.panic_strategy() == PanicStrategy::Abort {
2470-
"DISABLE_EXCEPTION_CATCHING=1"
2469+
cmd.cc_arg(if sess.panic_strategy() == PanicStrategy::Abort {
2470+
"-sDISABLE_EXCEPTION_CATCHING=1"
24712471
} else {
2472-
"DISABLE_EXCEPTION_CATCHING=0"
2472+
"-fwasm-exceptions"
24732473
});
24742474
}
24752475

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ pub(crate) fn build_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
388388
// exceptions. This means that the VM does the unwinding for
389389
// us
390390
pub fn wants_wasm_eh(sess: &Session) -> bool {
391-
sess.target.is_like_wasm && sess.target.os != "emscripten"
391+
sess.target.is_like_wasm
392392
}
393393

394394
/// Returns `true` if this session's target will use SEH-based unwinding.

compiler/rustc_passes/src/weak_lang_items.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ pub(crate) fn check_crate(
2626
if items.eh_personality().is_none() {
2727
items.missing.push(LangItem::EhPersonality);
2828
}
29-
if tcx.sess.target.os == "emscripten" && items.eh_catch_typeinfo().is_none() {
30-
items.missing.push(LangItem::EhCatchTypeinfo);
31-
}
29+
// if tcx.sess.target.os == "emscripten" && items.eh_catch_typeinfo().is_none() {
30+
// items.missing.push(LangItem::EhCatchTypeinfo);
31+
// }
3232

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

library/panic_unwind/src/lib.rs

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

3333
cfg_if::cfg_if! {
34-
if #[cfg(target_os = "emscripten")] {
35-
#[path = "emcc.rs"]
36-
mod imp;
37-
} else if #[cfg(target_os = "hermit")] {
34+
if #[cfg(target_os = "hermit")] {
3835
#[path = "hermit.rs"]
3936
mod imp;
4037
} else if #[cfg(target_os = "l4re")] {

library/unwind/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
#![feature(link_cfg)]
44
#![feature(staged_api)]
55
#![cfg_attr(not(target_env = "msvc"), feature(libc))]
6-
#![cfg_attr(
7-
all(target_family = "wasm", not(target_os = "emscripten")),
8-
feature(simd_wasm64, wasm_exception_handling_intrinsics)
9-
)]
6+
#![cfg_attr(all(target_family = "wasm"), feature(simd_wasm64, wasm_exception_handling_intrinsics))]
107
#![allow(internal_features)]
118

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

0 commit comments

Comments
 (0)