From 658a0a20eac4341e31c57cf08e019b53f09b93b4 Mon Sep 17 00:00:00 2001 From: Noa Date: Thu, 22 Feb 2024 16:52:48 -0600 Subject: [PATCH] Unconditionally pass -wasm-enable-eh --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 12 ++++++------ library/panic_unwind/src/lib.rs | 7 +------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index e383673e1d4..51e1f408a69 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -99,12 +99,12 @@ fn llvm_arg_to_arg_name(full_arg: &str) -> &str { } } - if sess.panic_strategy() == PanicStrategy::Unwind { - if sess.target.os == "emscripten" { - add("-enable-emscripten-cxx-exceptions", false); - } else if wants_wasm_eh(sess) { - add("-wasm-enable-eh", false); - } + if wants_wasm_eh(sess) { + add("-wasm-enable-eh", 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 diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs index bc3c9363d8a..37e1d2cf6d1 100644 --- a/library/panic_unwind/src/lib.rs +++ b/library/panic_unwind/src/lib.rs @@ -60,12 +60,7 @@ ))] { #[path = "gcc.rs"] mod real_imp; - } else if #[cfg(all(target_family = "wasm", panic = "unwind"))] { - // for now, PanicStrategy::Unwind is not the default for wasm targets, - // so we need the panic = "unwind" in the cfg above. to use llvm.wasm.throw, - // we need to pass -wasm-enable-eh to LLVM, but that only happens if rustc - // is compiling with -C panic=unwind. So, this lets us -Zbuild-std with - // panic=unwind, while keeping the default panic=abort working. + } else if #[cfg(target_family = "wasm")] { #[path = "wasm.rs"] mod real_imp; } else {