Skip to content

Commit a4fde11

Browse files
committed
Add emscripten_wasm_eh cfg flag and use it to adjust the libraries
1 parent 6e9ff3f commit a4fde11

File tree

7 files changed

+19
-5
lines changed

7 files changed

+19
-5
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2468,7 +2468,7 @@ 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 if (sess.unstable_options.emscripten_wasm_eh) {
2471+
} else if sess.opts.unstable_opts.emscripten_wasm_eh {
24722472
"-fwasm-exceptions"
24732473
} else {
24742474
"-sDISABLE_EXCEPTION_CATCHING=0"

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +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)
392+
&& (sess.target.os != "emscripten" || sess.opts.unstable_opts.emscripten_wasm_eh)
393393
}
394394

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

compiler/rustc_passes/src/weak_lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) fn check_crate(
2828
}
2929
if tcx.sess.target.os == "emscripten"
3030
&& items.eh_catch_typeinfo().is_none()
31-
&& !tcx.sess.unstable_options.emscripten_wasm_eh
31+
&& !tcx.sess.opts.unstable_opts.emscripten_wasm_eh
3232
{
3333
items.missing.push(LangItem::EhCatchTypeinfo);
3434
}

compiler/rustc_session/src/config/cfg.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) {
143143
| (sym::target_has_atomic_load_store, Some(_))
144144
| (sym::target_thread_local, None) => disallow(cfg, "--target"),
145145
(sym::fmt_debug, None | Some(_)) => disallow(cfg, "-Z fmt-debug"),
146+
(sym::emscripten_wasm_eh, None | Some(_)) => disallow(cfg, "-Z emscripten_wasm_eh"),
146147
_ => {}
147148
}
148149
}
@@ -295,6 +296,9 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
295296
ins_none!(sym::ub_checks);
296297
}
297298

299+
if sess.opts.unstable_opts.emscripten_wasm_eh {
300+
ins_none!(sym::emscripten_wasm_eh);
301+
}
298302
ret
299303
}
300304

@@ -350,6 +354,7 @@ impl CheckCfg {
350354
ins!(sym::clippy, no_values);
351355
ins!(sym::doc, no_values);
352356
ins!(sym::doctest, no_values);
357+
ins!(sym::emscripten_wasm_eh, no_values);
353358
ins!(sym::miri, no_values);
354359
ins!(sym::rustfmt, no_values);
355360

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ symbols! {
823823
emit_enum_variant_arg,
824824
emit_struct,
825825
emit_struct_field,
826+
emscripten_wasm_eh,
826827
enable,
827828
encode,
828829
end,

library/panic_unwind/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@
2525
// `real_imp` is unused with Miri, so silence warnings.
2626
#![cfg_attr(miri, allow(dead_code))]
2727
#![allow(internal_features)]
28+
#![cfg_attr(bootstrap, allow(unexpected_cfgs))]
2829

2930
use alloc::boxed::Box;
3031
use core::any::Any;
3132
use core::panic::PanicPayload;
3233

3334
cfg_if::cfg_if! {
34-
if #[cfg(target_os = "hermit")] {
35+
if #[cfg(all(target_os = "emscripten", not(emscripten_wasm_eh)))] {
36+
#[path = "emcc.rs"]
37+
mod imp;
38+
} else if #[cfg(target_os = "hermit")] {
3539
#[path = "hermit.rs"]
3640
mod imp;
3741
} else if #[cfg(target_os = "l4re")] {

library/unwind/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
#![feature(link_cfg)]
44
#![feature(staged_api)]
55
#![cfg_attr(not(target_env = "msvc"), feature(libc))]
6-
#![cfg_attr(all(target_family = "wasm"), feature(simd_wasm64, wasm_exception_handling_intrinsics))]
6+
#![cfg_attr(bootstrap, allow(unexpected_cfgs))]
7+
#![cfg_attr(
8+
all(target_family = "wasm", any(not(target_os = "emscripten"), emscripten_wasm_eh)),
9+
feature(simd_wasm64, wasm_exception_handling_intrinsics)
10+
)]
711
#![allow(internal_features)]
812

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

0 commit comments

Comments
 (0)