diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 8bf9f8420c05e..6752ddbc5706e 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -798,7 +798,7 @@ fn test_unstable_options_tracking_hash() { tracked!(embed_metadata, false); tracked!(embed_source, true); tracked!(emit_thin_lto, false); - tracked!(emscripten_wasm_eh, true); + tracked!(emscripten_wasm_eh, false); tracked!(export_executable_symbols, true); tracked!(fewer_names, Some(true)); tracked!(fixed_x18, true); diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 7c7e9118d590f..872a48efa3661 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -2338,7 +2338,7 @@ options! { "emit a section containing stack size metadata (default: no)"), emit_thin_lto: bool = (true, parse_bool, [TRACKED], "emit the bc module with thin LTO info (default: yes)"), - emscripten_wasm_eh: bool = (false, parse_bool, [TRACKED], + emscripten_wasm_eh: bool = (true, parse_bool, [TRACKED], "Use WebAssembly error handling for wasm32-unknown-emscripten"), enforce_type_length_limit: bool = (false, parse_bool, [TRACKED], "enforce the type length limit when monomorphizing instances in codegen"), diff --git a/src/doc/rustc/src/platform-support/wasm32-unknown-emscripten.md b/src/doc/rustc/src/platform-support/wasm32-unknown-emscripten.md index a9ff1ebd10488..d5e3125fd3c79 100644 --- a/src/doc/rustc/src/platform-support/wasm32-unknown-emscripten.md +++ b/src/doc/rustc/src/platform-support/wasm32-unknown-emscripten.md @@ -95,10 +95,11 @@ This target can be cross-compiled from any host. ## Emscripten ABI Compatibility The Emscripten compiler toolchain does not follow a semantic versioning scheme -that clearly indicates when breaking changes to the ABI can be made. Additionally, -Emscripten offers many different ABIs even for a single version of Emscripten -depending on the linker flags used, e.g. `-fexceptions` and `-sWASM_BIGINT`. If -the ABIs mismatch, your code may exhibit undefined behaviour. +that clearly indicates when breaking changes to the ABI can be made. +Additionally, Emscripten offers many different ABIs even for a single version of +Emscripten depending on the linker flags used, e.g. `-fwasm-exceptions` and +`-sWASM_BIGINT`. If the ABIs do not match, your code may exhibit undefined +behaviour. To ensure that the ABIs of your Rust code, of the Rust standard library, and of other code compiled for Emscripten all match, you should rebuild the Rust standard @@ -158,9 +159,9 @@ features can be disabled, and how Rust code can be conditionally compiled based which features are enabled. Note that Rust code compiled for `wasm32-unknown-emscripten` currently enables -`-fexceptions` (JS exceptions) by default unless the Rust code is compiled with -`-Cpanic=abort`. `-fwasm-exceptions` (WASM exceptions) is not yet currently supported, -see . +`-fwasm-exceptions` (legacy WASM exceptions) by default unless the Rust code is +compiled with `-Cpanic=abort`. It is possible to use JS exceptions by passing +the flag ``-Z emscripten-wasm-eh=false`` but this will be removed in the future. Please refer to the [Emscripten ABI compatibility](#emscripten-abi-compatibility) section to ensure that the features that are enabled do not cause an ABI mismatch diff --git a/tests/codegen-llvm/emscripten-catch-unwind-js-eh.rs b/tests/codegen-llvm/emscripten-catch-unwind-js-eh.rs index dfe154c1c8314..c641c0a63d541 100644 --- a/tests/codegen-llvm/emscripten-catch-unwind-js-eh.rs +++ b/tests/codegen-llvm/emscripten-catch-unwind-js-eh.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Copt-level=3 --target wasm32-unknown-emscripten +//@ compile-flags: -Copt-level=3 --target wasm32-unknown-emscripten -Z emscripten-wasm-eh=false //@ needs-llvm-components: webassembly // Emscripten has its own unique implementation of catch_unwind (in `codegen_emcc_try`), diff --git a/tests/ui/feature-gates/feature-gate-cfg-emscripten-wasm-eh.rs b/tests/ui/feature-gates/feature-gate-cfg-emscripten-wasm-eh.rs index 232061e239c93..a13e7fa317f5b 100644 --- a/tests/ui/feature-gates/feature-gate-cfg-emscripten-wasm-eh.rs +++ b/tests/ui/feature-gates/feature-gate-cfg-emscripten-wasm-eh.rs @@ -1,4 +1,4 @@ //@ compile-flags: --check-cfg=cfg(emscripten_wasm_eh) -#[cfg(not(emscripten_wasm_eh))] +#[cfg(emscripten_wasm_eh)] //~^ ERROR `cfg(emscripten_wasm_eh)` is experimental fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-cfg-emscripten-wasm-eh.stderr b/tests/ui/feature-gates/feature-gate-cfg-emscripten-wasm-eh.stderr index 67769e3c7586b..a829c9b93a566 100644 --- a/tests/ui/feature-gates/feature-gate-cfg-emscripten-wasm-eh.stderr +++ b/tests/ui/feature-gates/feature-gate-cfg-emscripten-wasm-eh.stderr @@ -1,8 +1,8 @@ error[E0658]: `cfg(emscripten_wasm_eh)` is experimental and subject to change - --> $DIR/feature-gate-cfg-emscripten-wasm-eh.rs:2:11 + --> $DIR/feature-gate-cfg-emscripten-wasm-eh.rs:2:7 | -LL | #[cfg(not(emscripten_wasm_eh))] - | ^^^^^^^^^^^^^^^^^^ +LL | #[cfg(emscripten_wasm_eh)] + | ^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(cfg_emscripten_wasm_eh)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date