Skip to content

Emscripten wasm32 compilation broken #85821

Closed

Description

@creikey

I tried this code:

fn main() {
    println!("Hello, world!");
}

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 properly

Instead, this happened: Prints this error:

  = note: error: undefined symbol: __gxx_personality_v0 (referenced by top-level compiled C/C++ code)
          warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
          warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
          warning: ___gxx_personality_v0 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
          Error: Aborting compilation due to previous errors
          emcc: error: 'C:/Users/camer/Documents/Tech/emsdk/node/14.15.5_64bit/bin/node.exe C:\Users\camer\Documents\Tech\emsdk\upstream\emscripten\src\compiler.js C:\Users\camer\AppData\Local\Temp\tmprxn1kc58.txt' failed (returned 1)

I've tried adding -lstdc++ to no avail

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (f58631b45 2021-05-28)
binary: rustc
commit-hash: f58631b4503b5cd34163cf9c3ff19dc3e0c8a09e
commit-date: 2021-05-28
host: x86_64-pc-windows-msvc
release: 1.54.0-nightly
LLVM version: 12.0.1
Backtrace

error: linking with `emcc.bat` failed: exit code: 1
  |
  = note: "cmd" "/c" "emcc.bat" "-s" "DISABLE_EXCEPTION_CATCHING=0" "-L" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib" "-L" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\self-contained" "main.main.7rcbfp3g-cgu.0.rcgu.o" "main.main.7rcbfp3g-cgu.1.rcgu.o" "main.main.7rcbfp3g-cgu.2.rcgu.o" "main.main.7rcbfp3g-cgu.3.rcgu.o" "main.main.7rcbfp3g-cgu.4.rcgu.o" "main.main.7rcbfp3g-cgu.5.rcgu.o" "main.main.7rcbfp3g-cgu.6.rcgu.o" "main.main.7rcbfp3g-cgu.7.rcgu.o" "-o" "main.js" "-s" "EXPORTED_FUNCTIONS=[\"_main\",\"_rust_eh_personality\"]" "main.4s37gsrti678ik8u.rcgu.o" "-O0" "--memory-init-file" "0" "-g0" "-s" "DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]" "-L" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libstd-fb3d38fb81b27f3a.rlib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libpanic_unwind-d2cae8b45410ca8e.rlib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libstd_detect-59eadd895a0069e7.rlib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\librustc_demangle-034447b1a63c6379.rlib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libhashbrown-3b180b71fa933791.rlib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\librustc_std_workspace_alloc-5d053d604e1da3fd.rlib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libunwind-835bbc670368e525.rlib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libcfg_if-8111a663608e727d.rlib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\liblibc-35dde82b6021f4d8.rlib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\liballoc-a187fd59d7a86f05.rlib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\librustc_std_workspace_core-81a0f0dbfa7b5ebf.rlib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libcore-ced9603eedaff686.rlib" "C:\\Users\\camer\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libcompiler_builtins-2960d62a9b1d31c1.rlib" "-l" "c" "-s" "ERROR_ON_UNDEFINED_SYMBOLS=1" "-s" "ASSERTIONS=1" "-s" "ABORTING_MALLOC=0" "-Wl,--fatal-warnings"
  = note: error: undefined symbol: __gxx_personality_v0 (referenced by top-level compiled C/C++ code)
          warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
          warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
          warning: ___gxx_personality_v0 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
          Error: Aborting compilation due to previous errors
          emcc: error: 'C:/Users/camer/Documents/Tech/emsdk/node/14.15.5_64bit/bin/node.exe C:\Users\camer\Documents\Tech\emsdk\upstream\emscripten\src\compiler.js C:\Users\camer\AppData\Local\Temp\tmp6dw5_wby.txt' failed (returned 1)


error: aborting due to previous error

Activity

  1. creikey commented on May 29, 2021

    @creikey
    Author
    emcc --check
    emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 2.0.23 (b15ca40ca02f469de3bf9a4de67a2655aede8974)
    

    runs successfully

  2. creikey commented on May 30, 2021

    @creikey
    Author

    Also is broken on ubuntu with the same error message (at least windows subsystem for linux)

  3. changed the title [-]Emscripten compilation broken on windows [/-] [+]Emscripten wasm32 compilation broken[/+] on May 30, 2021
  4. strager commented on Jun 1, 2021

    @strager

    rustc 1.53.0-nightly (42816d6 2021-04-24)
    emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 2.0.12 (d0e647bf266caad50943e78c9841e05e9c499a5d)

    Here's some info I gathered:

    I successfully compiled hello world with emscripten SDK version 2.0.9. That version still has the __gxx_personality_v0 stub.

  5. inquisitivecrystal commented on Jun 5, 2021

    @inquisitivecrystal
    Contributor

    @rustbot label I-prioritize T-compiler O-wasm

  6. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    O-wasmTarget: WASM (WebAssembly), http://webassembly.org/
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jun 5, 2021
  7. apiraino commented on Jun 9, 2021

    @apiraino
    Contributor

    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

  8. added
    P-highHigh priority
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jun 9, 2021
  9. lopopolo commented on Aug 5, 2021

    @lopopolo
    Contributor

    I recall with the LLVM 11 upgrade, the compat notes mentioned which version of Emscripten to use when compiling with the wasm32-unknown-emscripten target.

    https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1470-2020-10-08

    Bumped the minimum supported Emscripten version to 1.39.20.

    Once this bug is resolved, can we add a similar note for the releases that upgrade Rust to LLVM 12?

  10. 7 remaining items

  11. hoodmane commented on Jun 2, 2022

    @hoodmane
    Contributor

    Reported this on Emscripten:
    emscripten-core/emscripten#17128

  12. added a commit that references this issue on Jun 8, 2022
    2ecbdc1
  13. added 2 commits that reference this issue on Jun 9, 2022
    03b0f41
    20be5da
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions