Skip to content

Commit 6e9ff3f

Browse files
committed
Gate compiler changes on -Zemscripten-wasm-eh
1 parent f4634f0 commit 6e9ff3f

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,12 @@ 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"
113+
&& !sess.opts.unstable_opts.emscripten_wasm_eh
114+
&& sess.panic_strategy() == PanicStrategy::Unwind
115+
{
116+
add("-enable-emscripten-cxx-exceptions", false);
117+
}
115118

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

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2468,8 +2468,10 @@ fn add_order_independent_options(
24682468
if sess.target.os == "emscripten" {
24692469
cmd.cc_arg(if sess.panic_strategy() == PanicStrategy::Abort {
24702470
"-sDISABLE_EXCEPTION_CATCHING=1"
2471-
} else {
2471+
} else if (sess.unstable_options.emscripten_wasm_eh) {
24722472
"-fwasm-exceptions"
2473+
} else {
2474+
"-sDISABLE_EXCEPTION_CATCHING=0"
24732475
});
24742476
}
24752477

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ pub(crate) fn build_shift_expr_rhs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
389389
// us
390390
pub fn wants_wasm_eh(sess: &Session) -> bool {
391391
sess.target.is_like_wasm
392+
&& (sess.target.os != "emscripten" || sess.unstable_options.emscripten_wasm_eh)
392393
}
393394

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

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ fn test_unstable_options_tracking_hash() {
782782
tracked!(dwarf_version, Some(5));
783783
tracked!(embed_source, true);
784784
tracked!(emit_thin_lto, false);
785-
tracked!(emscripten_wasm_eh)
785+
tracked!(emscripten_wasm_eh);
786786
tracked!(export_executable_symbols, true);
787787
tracked!(fewer_names, Some(true));
788788
tracked!(fixed_x18, true);

compiler/rustc_passes/src/weak_lang_items.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ 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"
30+
&& items.eh_catch_typeinfo().is_none()
31+
&& !tcx.sess.unstable_options.emscripten_wasm_eh
32+
{
33+
items.missing.push(LangItem::EhCatchTypeinfo);
34+
}
3235

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

0 commit comments

Comments
 (0)