koute / stdweb

A standard library for the client-side Web
Apache License 2.0
3.44k stars 177 forks source link

unexpected char in asm const signature 101 #398

Open orthecreedence opened 4 years ago

orthecreedence commented 4 years ago

Hello! I'm trying out stdweb with emscripten (1.39.10) and running into an issue when calling stdweb::initialize():

exception thrown: RuntimeError: abort(unexpected char in asm const signature 101) at Error
    at jsStackTrace (http://localhost/turtl/tmp/wasm-test/echo.js:1842:17)
    at stackTrace (http://localhost/turtl/tmp/wasm-test/echo.js:1859:16)
    at abort (http://localhost/turtl/tmp/wasm-test/echo.js:1633:44)
    at readAsmConstArgs (http://localhost/turtl/tmp/wasm-test/echo.js:4583:14)
    at _emscripten_asm_const_ii (http://localhost/turtl/tmp/wasm-test/echo.js:1810:14)
    at stdweb::webcore::initialization::initialize::snippet::__cargo_web_snippet_16d36d978962b51d2e9b2d23aa2ea13de278c5da::h526c1ddf367112d7 (wasm-function[67]:0x1448)
    at stdweb::webcore::initialization::initialize::snippet::he435142440b4a0ae (wasm-function[62]:0x112d)
    at stdweb::webcore::initialization::initialize::he1834ceadb207305 (wasm-function[61]:0x1100)
    at echo::main::ha1f0499ee076f4f5 (wasm-function[50]:0xdbc)
    at std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h5dd44104d86e8134 (wasm-function[43]:0xa89),RuntimeError: abort(unexpected char in asm const signature 101) at Error
    at jsStackTrace (http://localhost/turtl/tmp/wasm-test/echo.js:1842:17)
    at stackTrace (http://localhost/turtl/tmp/wasm-test/echo.js:1859:16)
    at abort (http://localhost/turtl/tmp/wasm-test/echo.js:1633:44)
    at readAsmConstArgs (http://localhost/turtl/tmp/wasm-test/echo.js:4583:14)
    at _emscripten_asm_const_ii (http://localhost/turtl/tmp/wasm-test/echo.js:1810:14)
    at stdweb::webcore::initialization::initialize::snippet::__cargo_web_snippet_16d36d978962b51d2e9b2d23aa2ea13de278c5da::h526c1ddf367112d7 (wasm-function[67]:0x1448)
    at stdweb::webcore::initialization::initialize::snippet::he435142440b4a0ae (wasm-function[62]:0x112d)
    at stdweb::webcore::initialization::initialize::he1834ceadb207305 (wasm-function[61]:0x1100)
    at echo::main::ha1f0499ee076f4f5 (wasm-function[50]:0xdbc)
    at std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h5dd44104d86e8134 (wasm-function[43]:0xa89)
    at abort (http://localhost/turtl/tmp/wasm-test/echo.js:1639:9)
    at readAsmConstArgs (http://localhost/turtl/tmp/wasm-test/echo.js:4583:14)
    at _emscripten_asm_const_ii (http://localhost/turtl/tmp/wasm-test/echo.js:1810:14)
    at stdweb::webcore::initialization::initialize::snippet::__cargo_web_snippet_16d36d978962b51d2e9b2d23aa2ea13de278c5da::h526c1ddf367112d7 (wasm-function[67]:0x1448)
    at stdweb::webcore::initialization::initialize::snippet::he435142440b4a0ae (wasm-function[62]:0x112d)
    at stdweb::webcore::initialization::initialize::he1834ceadb207305 (wasm-function[61]:0x1100)
    at echo::main::ha1f0499ee076f4f5 (wasm-function[50]:0xdbc)
    at std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h5dd44104d86e8134 (wasm-function[43]:0xa89)
    at std::sys_common::backtrace::__rust_begin_short_backtrace::hd9c5581cc7670e4c (wasm-function[222]:0x9de2)
    at std::panicking::try::do_call::hd78f907bd46bdbd3 (wasm-function[235]:0xa909)
callMain @ echo.js:5223
doRun @ echo.js:5263
run @ echo.js:5278
runCaller @ echo.js:5175
removeRunDependency @ echo.js:1611
receiveInstance @ echo.js:1728
receiveInstantiatedSource @ echo.js:1745
Promise.then (async)
(anonymous) @ echo.js:1766
Promise.then (async)
instantiateAsync @ echo.js:1764
createWasm @ echo.js:1791
(anonymous) @ echo.js:4667

Here's my Cargo.toml:

[package]
name = "echo"
version = "0.1.0"
authors = ["Andrew Danger Lyon <orthecreedence@gmail.com>"]
edition = "2018"

[dependencies]
stdweb = { version = "0.4.20" }

And my program:

use stdweb;

fn main() {
    println!("init");
    stdweb::initialize();
    println!("loop");
    stdweb::event_loop();
}

Compiling via:

cargo build --target wasm32-unknown-emscripten

Then I do cp target/wasm32-unknown-emscripten/debug/echo.{js,wasm} /path/to/echo-web and I have a very simple index.html that loads the echo.js file. The above error occurs. Note that is does print "init" in the console, but does not print "loop." I get the same result in both Chrome/FF (latest versions).

Am I doing something wrong? Thanks!

vmosone commented 4 years ago

Hi,I also encountered the same problem

Build env:

emscripten (1.39.13)
stdweb = "0.4"
stdweb-derive = "0.5.1"`

Target: cargo build --release --target asmjs-unknown-emscripten

Run exceptions:

exception thrown: Error: abort(unexpected char in asm const signature 101) at Error
    at jsStackTrace (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:165930:12)
    at stackTrace (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:165945:11)
    at abort (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:164809:43)
    at readAsmConstArgs (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:169000:10)
    at _emscripten_asm_const_ii (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:165907:13)
    at Array.W3 (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:125946:7)
    at Array.dT (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:160270:19)
    at o3 (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:104256:25)
    at Module._main (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:169925:31)
    at callMain (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:170706:13),Error: abort(unexpected char in asm const signature 101) at Error
    at jsStackTrace (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:165930:12)
    at stackTrace (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:165945:11)
    at abort (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:164809:43)
    at readAsmConstArgs (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:169000:10)
    at _emscripten_asm_const_ii (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:165907:13)
    at Array.W3 (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:125946:7)
    at Array.dT (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:160270:19)
    at o3 (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:104256:25)
    at Module._main (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:169925:31)
    at callMain (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:170706:13)
    at abort (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:164811:8)
    at readAsmConstArgs (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:169000:10)
    at _emscripten_asm_const_ii (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:165907:13)
    at Array.W3 (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:125946:7)
    at Array.dT (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:160270:19)
    at o3 (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:104256:25)
    at Module._main (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:169925:31)
    at callMain (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:170706:13)
    at doRun (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:170744:21)
    at run (http://localhost:8000/target/asmjs-unknown-emscripten/release/gui_web1.js:170756:3)
io12 commented 4 years ago

I also ran into this problem

boydjohnson commented 4 years ago

My understanding is emscripten builds are broken on both stable and nightly for rustc since November 2019: https://github.com/rust-lang/rust/issues/66916. With just cargo build --target <some emscripten> you will get the error here. With cargo web build --target <some emscripten> you will get a linker error. That has been my experience. I used a september 2019 toolchain with success. rustup toolchain add nightly-2019-09-15 and cargo web +nightly-2019-09-15 build --release asmjs-unknown-emscripten.

orthecreedence commented 4 years ago

Thank you! I wondered if this was the case. I will give the old toolchain a shot