Skip to content

Commit

Permalink
Support Emscripten with Wasm EH
Browse files Browse the repository at this point in the history
  • Loading branch information
purplesyringa committed Jan 24, 2025
1 parent 9f875d4 commit 4f1dd6f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,17 @@ jobs:
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Test with panic backend (debug)
run: LITHIUM_BACKEND=panic cross test --target $target
- name: Test with Itanium backend (debug)
run: RUSTFLAGS="-Z emscripten_wasm_eh" LITHIUM_BACKEND=itanium cross test --target $target -Z build-std
- name: Test with Emscripten backend (debug)
run: LITHIUM_BACKEND=emscripten cross test --target $target
- name: Test with std thread locals (debug)
run: LITHIUM_THREAD_LOCAL=std cross test --target $target
- name: Test with panic backend (release)
run: LITHIUM_BACKEND=panic cross test --target $target --release
# XXX: https://github.com/rust-lang/rust/issues/132416
# - name: Test with Itanium backend (release)
# run: RUSTFLAGS="-Z emscripten_wasm_eh" LITHIUM_BACKEND=itanium cross test --target $target --release -Z build-std
- name: Test with Emscripten backend (release)
run: LITHIUM_BACKEND=emscripten cross test --target $target --release
- name: Test with std thread locals (release)
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn main() {
println!("cargo::rerun-if-env-changed=LITHIUM_BACKEND");
if let Ok(backend) = std::env::var("LITHIUM_BACKEND") {
println!("cargo::rustc-cfg=backend=\"{backend}\"");
} else if is_nightly && cfg("target_os") == "emscripten" {
} else if is_nightly && cfg("target_os") == "emscripten" && !has_cfg("emscripten_wasm_eh") {
println!("cargo::rustc-cfg=backend=\"emscripten\"");
} else if is_nightly
&& (has_cfg("unix")
Expand Down
15 changes: 8 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
//!
//! On nightly Rust, Lithium uses a custom mechanism on the following targets:
//!
//! |Target |Implementation|Performance |
//! |-------------------|--------------|---------------------------------------------|
//! |Linux, macOS |Itanium EH ABI|2.5x faster than panics |
//! |Windows (MSVC ABI) |SEH |1.5x faster than panics |
//! |Windows (GNU ABI) |Itanium EH ABI|2.5x faster than panics, but slower than MSVC|
//! |Emscripten |C++ exceptions|2x faster than panics |
//! |WASI |Itanium EH ABI|2.5x faster than panics |
//! |Target |Implementation |Performance |
//! |-------------------|---------------|---------------------------------------------|
//! |Linux, macOS |Itanium EH ABI |2.5x faster than panics |
//! |Windows (MSVC ABI) |SEH |1.5x faster than panics |
//! |Windows (GNU ABI) |Itanium EH ABI |2.5x faster than panics, but slower than MSVC|
//! |Emscripten (old EH)|C++ exceptions |2x faster than panics |
//! |Emscripten (new EH)|Wasm exceptions|2.5x faster than panics |
//! |WASI |Itanium EH ABI |2.5x faster than panics |
//!
//! Lithium strives to support all targets that Rust panics support. If Lithium does not work
//! correctly on such a target, please [open an issue](https://github.com/iex-rs/lithium/issues/).
Expand Down

0 comments on commit 4f1dd6f

Please sign in to comment.