Hi,
I cloned krypken's repo kripken/sql.js and updated emscripten and binaryen through emsdk (incoming branch of emscripten, commit 47c2c82; and master branch of binaryen, commit 9607b1b).
Here is the command I use (inspired from the one found in the Makefile).
emcc --memory-init-file 0 \
-s INLINING_LIMIT=50 \
-s RESERVED_FUNCTION_POINTERS=64 \
-s EXPORTED_FUNCTIONS=@exported_functions \
c/extension-functions.bc \
c/sqlite3.bc \
--post-js js/api.js \
-o build/index.html
In total I generate 4 different kinds of builds:
-O3)-s WASM=1)-O3 -s WASM=1)I tested each of them with the following browsers, on a Macbook Pro with macOS Sierra:
Here are my results:
| Browser | asm.js | asm.js -O3 | wasm | wasm -O3 |
| -------- | ------- | ---------- | ------ | ----------- |
| Chrome stable | Assertion failed1 | Works | WebAssembly.instantiate is not a function2 | WebAssembly.instantiate is not a function3 |
| Chrome canary | Assertion failed | Works | Assertion failed4 | Cannot read property apply of undefined5 |
| Firefox stable | Assertion failed6 | Works | WebAssembly.instantiate is not a function | unreachable code after the return statement7 |
| Firefox nightly | Assertion failed | Works | Assertion failed | unreachable code after the return statement |
If you want to run the same commands or see the builts, everything is on my repo: the commands are in package.json and the compiled files are in build.
Any idea about what's wrong? Thank you very much.
Below are the console logs from the browsers.
build-asm.html:1237 Assertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called)
build-asm.html:1249 Assertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called)
printErr @ build-asm.html:1249
abort @ build-asm.js:275250
assert @ build-asm.js:400
asm.stackAlloc @ build-asm.js:274817
(anonymous) @ build-asm.js:275304
build-asm.js:275267 Uncaught abort("Assertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called)") at Error
at jsStackTrace (http://localhost:3000/build-asm.js:1100:13)
at stackTrace (http://localhost:3000/build-asm.js:1117:12)
at abort (http://localhost:3000/build-asm.js:275261:44)
at assert (http://localhost:3000/build-asm.js:400:5)
at Object.asm.stackAlloc (http://localhost:3000/build-asm.js:274817:1)
at http://localhost:3000/build-asm.js:275304:19
abort @ build-asm.js:275267
assert @ build-asm.js:400
asm.stackAlloc @ build-asm.js:274817
(anonymous) @ build-asm.js:275304
build-wasm.html:1249 trying binaryen method: native-wasm
printErr @ build-wasm.html:1249
Module.asm @ build-wasm.js:1900
(anonymous) @ build-wasm.js:6176
build-wasm.html:1249 asynchronously preparing wasm
printErr @ build-wasm.html:1249
doNativeWasm @ build-wasm.js:1741
Module.asm @ build-wasm.js:1903
(anonymous) @ build-wasm.js:6176
build-wasm.js:1743 Uncaught TypeError: WebAssembly.instantiate is not a function
at doNativeWasm (build-wasm.js:1743)
at Object.Module.asm (build-wasm.js:1903)
at build-wasm.js:6176
doNativeWasm @ build-wasm.js:1743
Module.asm @ build-wasm.js:1903
(anonymous) @ build-wasm.js:6176
Same as 2. Only the line numbers are different.
Canary wasm
Assertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called)
build-wasm.html:1249 Assertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called)
build-wasm.js:6792 Uncaught abort("Assertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called)") at Error
at jsStackTrace (http://localhost:3000/build-wasm.js:1100:13)
at stackTrace (http://localhost:3000/build-wasm.js:1117:12)
at abort (http://localhost:3000/build-wasm.js:6786:44)
at assert (http://localhost:3000/build-wasm.js:400:5)
at asm.stackAlloc (http://localhost:3000/build-wasm.js:6317:1)
at Object.Module.stackAlloc (http://localhost:3000/build-wasm.js:6497:89)
at http://localhost:3000/build-wasm.js:6829:19
build-wasm.html:1249 [post-exception status] All downloads complete.
build-wasm.html:1249 [post-exception status] Running...
build-wasm-O3.js:6067 Uncaught TypeError: Cannot read property 'apply' of undefined
at Object.Module.stackAlloc (build-wasm-O3.js:6067)
at build-wasm-O3.js:6386
build-wasm-O3.html:1249 [post-exception status] All downloads complete.
build-wasm-O3.html:1249 [post-exception status] Running...
Assertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called) build-asm.html:1249:13
Stack
abort:275267
assert:400
asm.stackAlloc:274817
(global):275304
unreachable code after return statement[Learn More]
Stack:
integrateWasmJS/Module.asm:1823
(global):6038
If you need more logs, please let me know. Thank you.
sql.js hasn't been updated in a while, I guess. The issues are:
Thanks Alon. We were able to compile everything with your recommendation. PR incoming on sql.js.
This PR https://github.com/kripken/sql.js/pull/189 should fix all the issues.
Most helpful comment
sql.js hasn't been updated in a while, I guess. The issues are: