Skip to content
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 builds broken on nightly? (Linking errors in fresh "hello world" crate) #66916

Open
elidupree opened this issue Dec 1, 2019 · 11 comments
Assignees
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example O-emscripten Target: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL! O-wasm Target: WASM (WebAssembly), http://webassembly.org/ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@elidupree
Copy link

elidupree commented Dec 1, 2019

I have the current nightly (did rustup update today), current cargo-web (0.6.26), and if I do cargo new followed by cargo web start --target=wasm32-unknown-emscripten, I get linking errors.

Same error occurs on nightly-2019-11-25. Also occurs when the target is asmjs-unknown-emscripten. The build succeeds on stable (1.39.0), and succeeds on nightly when the target is wasm32-unknown-unknown.

Example commandline output:

$ cargo web start --target=wasm32-unknown-emscripten --verbose
info: downloading component 'rust-std' for 'wasm32-unknown-emscripten'
info: installing component 'rust-std' for 'wasm32-unknown-emscripten'
   Compiling rust_emscripten_test v0.1.0 (/n/junk/rust_emscripten_test)
     Running `rustc --edition=2018 --crate-name rust_emscripten_test src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=6c74eb2532e4ce4c --out-dir /n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps --target wasm32-unknown-emscripten -C incremental=/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/incremental -L dependency=/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps -L dependency=/n/junk/rust_emscripten_test/target/debug/deps --cfg cargo_web -C link-arg=-s -C link-arg=NO_EXIT_RUNTIME=1 -C link-arg=-s -C link-arg=ALLOW_MEMORY_GROWTH=1`
error: linking with `emcc` failed: exit code: 1
  |
  = note: "emcc" "-s" "DISABLE_EXCEPTION_CATCHING=0" "-L" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib" "/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.3effavo9onmh17hh.rcgu.o" "/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.3jhw78ilx9rc2ys8.rcgu.o" "/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.40bcesoxxieo28hi.rcgu.o" "/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.43du0ixpxk05i5xw.rcgu.o" "/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.77fq9ag17u8dhov.rcgu.o" "/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.y2v92ehm3d15aty.rcgu.o" "-o" "/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.js" "-s" "EXPORTED_FUNCTIONS=[\"_main\",\"_rust_eh_personality\"]" "/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.2zo8kgta1jtd5lj3.rcgu.o" "-O0" "--memory-init-file" "0" "-g4" "-s" "DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[]" "-L" "/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps" "-L" "/n/junk/rust_emscripten_test/target/debug/deps" "-L" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libstd-1fcfbd12280fae19.rlib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libpanic_unwind-c611e0a491081e5f.rlib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libhashbrown-607c8cbf81c3463a.rlib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/librustc_std_workspace_alloc-0cfc23cf52635c24.rlib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libbacktrace-432c039f2b9d4ddc.rlib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/librustc_demangle-3977dea4164900ab.rlib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libunwind-12a8c7fb5b3a6c42.rlib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcfg_if-43bf8ebede870373.rlib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/liblibc-8addec02b212c706.rlib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/liballoc-bd32e0e1475a4f82.rlib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/librustc_std_workspace_core-9de912f7a3da239b.rlib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcore-5e42171377e616dd.rlib" "/n/HOME/.rustup/toolchains/nightly-2019-11-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-emscripten/lib/libcompiler_builtins-9517bbf2b8ee524b.rlib" "-l" "c" "-s" "NO_EXIT_RUNTIME=1" "-s" "ALLOW_MEMORY_GROWTH=1" "-s" "ERROR_ON_UNDEFINED_SYMBOLS=1" "-s" "ASSERTIONS=1" "-s" "ABORTING_MALLOC=0" "-Wl,--fatal-warnings"
  = note: WARNING:root:/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.3effavo9onmh17hh.rcgu.o is not valid LLVM bitcode
          WARNING:root:/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.3jhw78ilx9rc2ys8.rcgu.o is not valid LLVM bitcode
          WARNING:root:/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.40bcesoxxieo28hi.rcgu.o is not valid LLVM bitcode
          WARNING:root:/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.43du0ixpxk05i5xw.rcgu.o is not valid LLVM bitcode
          WARNING:root:/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.77fq9ag17u8dhov.rcgu.o is not valid LLVM bitcode
          WARNING:root:/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.y2v92ehm3d15aty.rcgu.o is not valid LLVM bitcode
          WARNING:root:/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps/rust_emscripten_test.2zo8kgta1jtd5lj3.rcgu.o is not valid LLVM bitcode
          WARNING:root:object /tmp/emscripten_temp_dFv8u4_archive_contents/std-1fcfbd12280fae19.std.5c9ljwyk-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_dFv8u4_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_dFv8u4_archive_contents/std-1fcfbd12280fae19.std.5c9ljwyk-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_cgKpQq_archive_contents/panic_unwind-c611e0a491081e5f.panic_unwind.23rlr7ip-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_cgKpQq_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_cgKpQq_archive_contents/panic_unwind-c611e0a491081e5f.panic_unwind.23rlr7ip-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_SIoCtx_archive_contents/hashbrown-607c8cbf81c3463a.hashbrown.5152pmq1-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_SIoCtx_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_SIoCtx_archive_contents/hashbrown-607c8cbf81c3463a.hashbrown.5152pmq1-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_wFFRHN_archive_contents/rustc_std_workspace_alloc-0cfc23cf52635c24.rustc_std_workspace_alloc.83s1ivy8-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_wFFRHN_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_wFFRHN_archive_contents/rustc_std_workspace_alloc-0cfc23cf52635c24.rustc_std_workspace_alloc.83s1ivy8-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_2nPYgD_archive_contents/backtrace-432c039f2b9d4ddc.backtrace.d8lkv2lk-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_2nPYgD_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_2nPYgD_archive_contents/backtrace-432c039f2b9d4ddc.backtrace.d8lkv2lk-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_o9MxQI_archive_contents/rustc_demangle-3977dea4164900ab.rustc_demangle.7xkz49id-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_o9MxQI_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_o9MxQI_archive_contents/rustc_demangle-3977dea4164900ab.rustc_demangle.7xkz49id-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_lyFnCB_archive_contents/unwind-12a8c7fb5b3a6c42.unwind.9khdj4dv-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_lyFnCB_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_lyFnCB_archive_contents/unwind-12a8c7fb5b3a6c42.unwind.9khdj4dv-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_93exa9_archive_contents/cfg_if-43bf8ebede870373.cfg_if.41g2jzan-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_93exa9_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_93exa9_archive_contents/cfg_if-43bf8ebede870373.cfg_if.41g2jzan-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_HYmpWR_archive_contents/libc-8addec02b212c706.libc.716tw7zw-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_HYmpWR_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_HYmpWR_archive_contents/libc-8addec02b212c706.libc.716tw7zw-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_0CLSbW_archive_contents/alloc-bd32e0e1475a4f82.alloc.32w6a2l7-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_0CLSbW_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_0CLSbW_archive_contents/alloc-bd32e0e1475a4f82.alloc.32w6a2l7-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_rI_TbG_archive_contents/rustc_std_workspace_core-9de912f7a3da239b.rustc_std_workspace_core.6km2rhby-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_rI_TbG_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_rI_TbG_archive_contents/rustc_std_workspace_core-9de912f7a3da239b.rustc_std_workspace_core.6km2rhby-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_P5Xd4R_archive_contents/core-5e42171377e616dd.core.7ijpxdtg-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_P5Xd4R_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_P5Xd4R_archive_contents/core-5e42171377e616dd.core.7ijpxdtg-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_fgzoAU_archive_contents/compiler_builtins-9517bbf2b8ee524b.compiler_builtins.5ji0j36k-cgu.0.rcgu.o is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_fgzoAU_archive_contents/lib.rmeta is not valid according to llvm-nm, cannot link
          WARNING:root:object /tmp/emscripten_temp_fgzoAU_archive_contents/compiler_builtins-9517bbf2b8ee524b.compiler_builtins.5ji0j36k-cgu.0.rcgu.bc.z is not valid according to llvm-nm, cannot link
          ERROR:root:undefined exported function: "_main"
          

error: aborting due to previous error
error: could not compile `rust_emscripten_test`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name rust_emscripten_test src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=6c74eb2532e4ce4c --out-dir /n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps --target wasm32-unknown-emscripten -C incremental=/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/incremental -L dependency=/n/junk/rust_emscripten_test/target/wasm32-unknown-emscripten/debug/deps -L dependency=/n/junk/rust_emscripten_test/target/debug/deps --cfg cargo_web -C link-arg=-s -C link-arg=NO_EXIT_RUNTIME=1 -C link-arg=-s -C link-arg=ALLOW_MEMORY_GROWTH=1` (exit code: 1)
error: build failed
@celestefox
Copy link

I can reproduce this too, FWIW, with a couple more warnings at the start, though I'm not sure if it's relevant:

...
= note: /home/myst/.local/share/cargo-web/emscripten/x86_64-unknown-linux-
gnu/emscripten/emcc.py:812: SyntaxWarning: "is not" with a literal. Did you mean "!="?
            newargs = [arg for arg in newargs if arg is not '']
          /home/myst/.local/share/cargo-web/emscripten/x86_64-unknown-linux-
gnu/emscripten/emcc.py:923: SyntaxWarning: "is not" with a literal. Did you
mean "!="?                                                                              newargs = [a for a in newargs if a is not '']
          WARNING:root:/home/myst/emsctesr/target/wasm32-unknown-emscripten/
debug/deps/emsctesr.1cna8owmye1j1q9.rcgu.o is not valid LLVM bitcode
...

@jonas-schievink jonas-schievink added A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. I-nominated O-wasm Target: WASM (WebAssembly), http://webassembly.org/ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 1, 2019
@pnkfelix pnkfelix added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example P-high High priority and removed I-nominated labels Dec 5, 2019
@pnkfelix
Copy link
Member

pnkfelix commented Dec 5, 2019

triage: Needs reduction to MCVE. P-high. Removing nomination.

@jonas-schievink jonas-schievink added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Jan 9, 2020
@elichai
Copy link
Contributor

elichai commented Jan 29, 2020

Ping? still broken on latest nightly (3761dcd 2020-01-28)

Would really appreciate a fix that could land in the next stable (this is basically the only way to test that code works(not just compiles) on wasm)

elichai added a commit to elichai/rust-secp256k1 that referenced this issue Mar 11, 2020
ordian added a commit to ordian/rust-secp256k1 that referenced this issue Apr 9, 2020
* rust-bitcoin/master:
  Fix no-std raw test, after removal of lang items
  Fix broken benchmarks
  Disable emscripten tests until they work again rust-lang/rust#66916 rustwasm/team#291
  Add constant of the prime of the curve field.
  Simplify callback logic to returning raw coordinates
  Removed no longer used dont_replace_c_symbols feature
  Fix wrong feature name external-symbols
  Fix missing return c_int in NonceFn
tronical added a commit to slint-ui/slint that referenced this issue Jun 8, 2020
This reverts commit aef96cb, commit
1b2d0a3, and commit
82214dc.

The wasm32-unknown-emscripten target is not very well supported right
now, from build issues in instant/winit to toolchain issues
(rust-lang/rust#66916).

So let's not go down that route for now.
@Revlin
Copy link

Revlin commented Jan 8, 2021

Example: https://github.com/Revlin/wasm-rust-emscripten

cargo build --target wasm32-unknown-emscripten compiles and links, but appears to produce invalid wasm output, using Emscripten SDK version 1.39.20 (is there a new version that will link successfully?). Can no longer bundle this target using webpack (see link above to reproduce):

$ rustup target add wasm32-unknown-emscripten
    ...

$ cargo install wasm-bindgen-cli
    ...

$ cargo build --target wasm32-unknown-emscripten
    Compiling ...

$ wasm-bindgen target/wasm32-unknown-emscripten/debug/bindgenhello.wasm --out-dir target/wasm32-unknown-emscripten/debug

$ webpack bundle

(node:160144) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
        Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
        Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
assets by status 132 KiB [cached] 1 asset
assets by status 20.1 KiB [emitted]
  asset index.js 12.2 KiB [emitted] (name: main)
  asset target_wasm32-unknown-emscripten_debug_bindgenhello_js.index.js 7.89 KiB [emitted]
asset index.html 226 bytes [compared for emit]
runtime modules 6.95 KiB 9 modules
cacheable modules 703 bytes (javascript) 132 KiB (webassembly)
  modules by path ./target/wasm32-unknown-emscripten/debug/*.js 134 bytes
    ./target/wasm32-unknown-emscripten/debug/bindgenhello.js 85 bytes [built] [code generated]
    ./target/wasm32-unknown-emscripten/debug/bindgenhello_bg.js 49 bytes [built] [code generated]
  ./index.js 249 bytes [built] [code generated]
  ./target/wasm32-unknown-emscripten/debug/bindgenhello_bg.wasm 320 bytes (javascript) 132 KiB (webassembly) [built] [code generated]

ERROR in ./target/wasm32-unknown-emscripten/debug/bindgenhello_bg.wasm
Module not found: Error: Can't resolve 'env' in '/home/revlin/Public/edu/rust/target/wasm32-unknown-emscripten/debug'
 @ ./target/wasm32-unknown-emscripten/debug/bindgenhello.js 1:0-47
 @ ./index.js 2:13-76

ERROR in ./target/wasm32-unknown-emscripten/debug/bindgenhello_bg.wasm
Module not found: Error: Can't resolve 'wasi_snapshot_preview1' in '/home/revlin/Public/edu/rust/target/wasm32-unknown-emscripten/debug'
 @ ./target/wasm32-unknown-emscripten/debug/bindgenhello.js 1:0-47
 @ ./index.js 2:13-76

webpack 5.12.1 compiled with 2 errors in 349 ms

@Subsentient
Copy link

Was looking forward to using Rust in an ASM.JS project (wasm2js), found this bug, which has clearly been around for a year and a half with no fix.

wasm_bindgen doesn't support ASM.JS at all, it gives back garbage after conversion from wasm. Therefore, I looked towards the emscripten targets so I could potentially use emscripten's asm to access JS without wasm_bindgen. And it's broken.
So Rust no longer supports ASM.JS in any capacity. Noted.

We both know it'll never get fixed. You'll just kill off the emscripten targets and pure WASM will be required forever more.

@MolotovCherry
Copy link

MolotovCherry commented Apr 10, 2022

For the .rmeta problem, there's a patch fix on #92738 which worked for me on emsripten 3.1.8.

Latest builds using Rust 1.59.0 and emscripten 3.1.8 are broken from the main thing, which can be fixed by fixing some stuff before entering the cmd:

@echo off

call emsdk/emsdk_env >NUL 2>NUL
set EMCC_CFLAGS=-s ERROR_ON_UNDEFINED_SYMBOLS=0 --no-entry

cmd /k

Now that it builds however, you will still get Module not found: Error: Can't resolve 'env'

So the generated binary seems to be broken, hmm


Edit: This seems to be related to the way emscripten works. It may very well not be broken, but it needs additional js to setup the env properly. Please see
https://stackoverflow.com/a/42694162/9423933

So it seems what we're encountering isn't something that's broken, but something that's more unfinished in generating the output, as Rust doesn't set these up properly

@wesleywiser wesleywiser self-assigned this Jun 10, 2022
@hoodmane
Copy link
Contributor

I think the problem is that cargo web start uses Emscripten v.1.38.19 which came out on Nov 15 2018. With a more recent version of Emscripten this works fine.

@wesleywiser
Copy link
Member

Interesting! What version of Emscripten are you using @hoodmane?

@hoodmane
Copy link
Contributor

Well I just checked it on v3.1.6 (Feb 24 2022), 3.1.13 (Jun 3 2022), and tip of tree. I am pretty sure it also works on 2.0.24 (Jun 10 2021).

@MolotovCherry
Copy link

Personally I was also trying the latest version and got these errors. But I was also using it with an already existing library (tree-sitter), and trying to compile it together with the rust module.

@pnkfelix
Copy link
Member

Visiting for P-high review

@rustbot claim

@rustbot rustbot assigned pnkfelix and unassigned wesleywiser Dec 16, 2022
@workingjubilee workingjubilee added the O-emscripten Target: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL! label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example O-emscripten Target: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL! O-wasm Target: WASM (WebAssembly), http://webassembly.org/ P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests