-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emscripten wasm32 compilation broken #85821
Comments
runs successfully |
Also is broken on ubuntu with the same error message (at least windows subsystem for linux) |
rustc 1.53.0-nightly (42816d6 2021-04-24) Here's some info I gathered:
I successfully compiled hello world with emscripten SDK version 2.0.9. That version still has the |
@rustbot label I-prioritize T-compiler O-wasm |
thanks @strager for the analysis. Assigning priority as discussed in the Zulip thread of the Prioritization Working Group. Let's find someone who can have a look at this. @rustbot label -I-prioritize +P-high +I-nominated |
I recall with the LLVM 11 upgrade, the compat notes mentioned which version of Emscripten to use when compiling with the https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1470-2020-10-08 Once this bug is resolved, can we add a similar note for the releases that upgrade Rust to LLVM 12? |
Followup to #1305 and #1306. rm -r artichoke-backend/vendor/emscripten/system/* cp -r ../playground/emsdk/upstream/emscripten/system/* artichoke-backend/vendor/emscripten/system/ These headers will match the version of emscripten used to compile the playground with Rust 1.54.0 which requires LLVM 12. See also rust-lang/rust#85821 for how this emsdk version was chosen.
Artichoke only compiles with Rust 1.54.0. Rust 1.54.0 is based on LLVM 12 (rust-lang/rust#81451). To ensure the `emcc` compiled sources interop with Rust code, it is important to use an `emsdk` version that is ~close to when it was branched from LLVM 12. According to the release notes [0], 2.0.23 - 05/26/2021 release is the first to be based on LLVM 12. However, Rust depends on a stubbed function in the emsdk c++ ABI that was removed in 2.0.10. According to rust-lang/rust#85821, we might have luck compiling with 2.0.9 [0]: https://emscripten.org/docs/introducing_emscripten/release_notes.html emscripten-toolchain
As @strager mentioned the panic=unwind strategy is broken on wasm32-unknown-emscripten. I recommend to switch default to panic=abort. Note that also rust std lib has to be rebuilt with panic=abort to fix the undefined symbol errors. Testing on my side showed that the problem could be fixed by changing TargetOptions on line 38 to "panic_strategy: PanicStrategy::Abort," in rust/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs file. Unfortunatelly I do not have experience in preparing pull request and have no capacity to get into it now. |
This issue can be solved by setting the env var See this comment - #41750 (comment) Passing these flags using the
I received this error in two places, one for symbol |
Change default panic strategy to abort for wasm32-unknown-emscripten Emscripten v2.0.10 removed __gxx_personality_v0 function stub that panic-unwind in wam32-unknown-emscripten target depends on. This causes linker error when using newer versions of emscripten compiler. As mentioned in rust-lang#85821 (comment) the __gxx_personality_v0 function was just a stub in emscripten for several years and therefor the panic-unwind strategy was broken all the time. Changing default to abort fixes builds (issue 85821) with recent version of emscripten yet we are not loosing any functionality as the panic-unwind was broken anyway. Fixes rust-lang#85821
This is adapted from https://github.com/tuxmark5/rust-skia. Build is working with emscripten 3.1.1, but requires setting some environment: EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0" EMSDK=~/.asdf/installs/emsdk/3.1.1 cargo build --target wasm32-unknown-emscripten EMCC_CFLAGS=... is a workaround for: warning: ___gxx_personality_v0 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library This error appeared with emscripten 2.0.10 and has yet to be fixed in rust: rust-lang/rust#85821 (comment) EMSDK=... is for building skia-bindings against emscripten's platform includes.
This is adapted from https://github.com/tuxmark5/rust-skia. Build is working with emscripten 3.1.1, but requires setting some environment variables: EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0" EMSDK=~/.asdf/installs/emsdk/3.1.1 cargo build --target wasm32-unknown-emscripten EMCC_CFLAGS=... is a workaround for: warning: ___gxx_personality_v0 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library This error appeared with emscripten 2.0.10 and has yet to be fixed in rust: rust-lang/rust#85821 (comment) EMSDK=... is for building skia-bindings against emscripten's platform includes.
Build is working with emscripten 3.1.1, but requires setting some environment variables: EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0" EMSDK=~/.asdf/installs/emsdk/3.1.1 cargo build --target wasm32-unknown-emscripten EMCC_CFLAGS=... is a workaround for: warning: ___gxx_personality_v0 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library This error appeared with emscripten 2.0.10 and has yet to be fixed in rust: rust-lang/rust#85821 (comment) EMSDK=... is for building skia-bindings against emscripten's platform includes. This is adapted from https://github.com/tuxmark5/rust-skia.
Build is working with emscripten 3.1.1, but requires setting some environment variables: EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0" EMSDK=~/.asdf/installs/emsdk/3.1.1 cargo build --target wasm32-unknown-emscripten EMCC_CFLAGS=... is a workaround for: warning: ___gxx_personality_v0 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library This error appeared with emscripten 2.0.10 and has yet to be fixed in rust: rust-lang/rust#85821 (comment) EMSDK=... is for building skia-bindings against emscripten's platform includes. This is adapted from https://github.com/tuxmark5/rust-skia.
Build is working with emscripten 3.1.1, but requires setting some environment variables: EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0" EMSDK=~/.asdf/installs/emsdk/3.1.1 cargo build --target wasm32-unknown-emscripten ERROR_ON_UNDEFINED_SYMBOLS is a workaround for: warning: ___gxx_personality_v0 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library This error appeared with emscripten 2.0.10 and has yet to be fixed in rust: rust-lang/rust#85821 (comment) EMSDK is for building skia-bindings against emscripten's platform includes. This is adapted from https://github.com/tuxmark5/rust-skia.
Build is working with emscripten 3.1.1, but requires setting some environment variables: EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0" EMSDK=~/.asdf/installs/emsdk/3.1.1 cargo build --target wasm32-unknown-emscripten ERROR_ON_UNDEFINED_SYMBOLS is a workaround for: warning: ___gxx_personality_v0 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library This error appeared with emscripten 2.0.10 and has yet to be fixed in rust: rust-lang/rust#85821 (comment) EMSDK is for building skia-bindings against emscripten's platform includes. This is adapted from https://github.com/tuxmark5/rust-skia.
Build is working with emscripten 3.1.1, but requires setting some environment variables: EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0" EMSDK=~/.asdf/installs/emsdk/3.1.1 cargo build --target wasm32-unknown-emscripten ERROR_ON_UNDEFINED_SYMBOLS is a workaround for: warning: ___gxx_personality_v0 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library This error appeared with emscripten 2.0.10 and has yet to be fixed in rust: rust-lang/rust#85821 (comment) EMSDK is for building skia-bindings against emscripten's platform includes. This is adapted from https://github.com/tuxmark5/rust-skia.
Reported this on Emscripten: |
… r=Amanieu Don't use __gxx_personality_v0 in panic_unwind on emscripten target This resolves rust-lang#85821. See also the discussion here: emscripten-core/emscripten#17128 The consensus seems to be that rust_eh_personality is never invoked. I patched __gxx_personality_v0 to log invocations and then ran various panic tests and it was never called, so this analysis matches what seems to happen in practice. This replaces the definition with an abort, modeled on the structured exception handling implementation.
… r=Amanieu Don't use __gxx_personality_v0 in panic_unwind on emscripten target This resolves rust-lang#85821. See also the discussion here: emscripten-core/emscripten#17128 The consensus seems to be that rust_eh_personality is never invoked. I patched __gxx_personality_v0 to log invocations and then ran various panic tests and it was never called, so this analysis matches what seems to happen in practice. This replaces the definition with an abort, modeled on the structured exception handling implementation.
I tried this code:
I expected to see this happen: Compiling with
rustc --target=wasm32-unknown-emscripten main.rs
, after the emsdk is activated and emcc works, to compile properlyInstead, this happened: Prints this error:
I've tried adding
-lstdc++
to no availMeta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: