asm.js output not running with 1.39.8

100 views
Skip to first unread message

Laurent Pugin

unread,
Feb 18, 2020, 2:16:24 AM2/18/20
to emscripten-discuss
Hi,

I have a problem with a project that builds asm.js output with the following parameters. 

my $FLAGS = "-O3";
$FLAGS .= " -DNDEBUG";
$FLAGS .= " --memory-init-file 0";
$FLAGS .= " -std=c++17";
$FLAGS .= " -s ASM_JS=1";
$FLAGS .= " -s WASM=0";
$FLAGS .= " -s TOTAL_MEMORY=256MB";
$FLAGS .= " -s TOTAL_STACK=128MB";

It generates a single JS file that can be included in a webpage within a <script> tag in the header, and then exported function are accessible. This used to work fine up to 1.39.7 but fails with 1.39.8. Any ideas of what has changed between the two versions and how to fix it? Thanks

The console throws (Chrome)

verovio-toolkit.js:43 failed to asynchronously prepare wasm: ReferenceError: oa is not defined
(anonymous) @ verovio-toolkit.js:43
Promise.then (async)
instantiateArrayBuffer @ verovio-toolkit.js:43
instantiateAsync @ verovio-toolkit.js:43
createWasm @ verovio-toolkit.js:43
(anonymous) @ verovio-toolkit.js:43
verovio-toolkit.js:43 ReferenceError: oa is not defined
verovio-toolkit.js:43 ReferenceError: oa is not defined
abort @ verovio-toolkit.js:43
(anonymous) @ verovio-toolkit.js:43
Promise.then (async)
instantiateArrayBuffer @ verovio-toolkit.js:43
instantiateAsync @ verovio-toolkit.js:43
createWasm @ verovio-toolkit.js:43
(anonymous) @ verovio-toolkit.js:43
verovio-toolkit.js:43 Uncaught (in promise) Error: abort(ReferenceError: oa is not defined). Build with -s ASSERTIONS=1 for more info.
at abort (verovio-toolkit.js:43)
at verovio-toolkit.js:43
abort @ verovio-toolkit.js:43
(anonymous) @ verovio-toolkit.js:43
Promise.then (async)
instantiateArrayBuffer @ verovio-toolkit.js:43
instantiateAsync @ verovio-toolkit.js:43
createWasm @ verovio-toolkit.js:43
(anonymous) @ verovio-toolkit.js:43
verovio-toolkit.js:43 Uncaught TypeError: Cannot read property 'apply' of undefined
at Object.Module._vrvToolkit_constructor [as constructor] (verovio-toolkit.js:43)
at new verovio.toolkit (verovio-toolkit.js:135)
at verovio.js:3
Module._vrvToolkit_constructor @ verovio-toolkit.js:43
verovio.toolkit @ verovio-toolkit.js:135
(anonymous) @ verovio.js:3

Firefox

failed to asynchronously prepare wasm: ReferenceError: oa is not defined verovio-toolkit-light.js:43:10692
ReferenceError: oa is not defined verovio-toolkit-light.js:43:9036
ReferenceError: oa is not defined verovio-toolkit-light.js:43:9046
Error: abort(ReferenceError: oa is not defined). Build with -s ASSERTIONS=1 for more info.
TypeError: Module.asm.vrvToolkit_constructor is undefinedverovio-toolkit-light.js:43:85119





Alon Zakai

unread,
Feb 18, 2020, 4:37:49 PM2/18/20
to emscripte...@googlegroups.com
Hmm, this is puzzling. Nothing in that range on emscripten looks suspicious, except perhaps for closure - do you have any other link flags, like --closure 1, than those mentioned?

If that's not it, perhaps this is a regression in Binaryen's wasm2js. To confirm, this is with 1.39.8 or 1.39.8-upstream, and and not 1.39.8-fastcomp?

Do you also get an error when building with -O0 or -O1? The error message might be clearer.


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/9619c413-0463-427e-ae26-27c41942466d%40googlegroups.com.

Laurent Pugin

unread,
Feb 19, 2020, 2:43:50 AM2/19/20
to emscripten-discuss
There are no other flags (except for the exported functions). It is using upstream.

I tested with other optimization flags.

With -O0: it compiles and runs as normal
With -O2 and -O3: it compiles but fails to run as reported before
With -O1: compilation fails with

Fatal: local.get of unknown in arg0 of call to emscripten_asm_const_int (used by EM_ASM* macros) in function 18029.
This might be caused by aggressive compiler transformations. Consider using EM_JS instead.
shared:ERROR: '/Users/laurent/tools/emsdk/upstream/bin/wasm-emscripten-finalize --detect-features --global-base=1024 /var/folders/wd/7vt44b8n035_qp6k8mt55rdr0000gn/T/emscripten_temp_ue0ycr/verovio.wasm -o /var/folders/wd/7vt44b8n035_qp6k8mt55rdr0000gn/T/emscripten_temp_ue0ycr/verovio.wasm.o.wasm' failed (1)
 Failed.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
Feb 19, 2020, 3:59:35 PM2/19/20
to emscripte...@googlegroups.com
Thanks, I see. Ok, this looks like a wasm2js bug.

Any chance you can provide the project so I can build locally to test? If not, if you can provide the build output with  -g1  (so there is whitespace) that might (but no sure) be enough to figure this out.

(The -O1 issue is a known limitation of EM_ASM currently. As the error suggests, EM_JS is a workaround, which is also better anyhow, so best to switch to that.)

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/6fe85c54-f3a2-44c6-bb2c-26002a3e14ef%40googlegroups.com.

Laurent Pugin

unread,
Feb 20, 2020, 1:46:44 AM2/20/20
to emscripten-discuss


Checkout the default (develop) branch, and in ./emscripten run ./buildToolkit -c -H

The options a given here

Thanks
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
Feb 20, 2020, 10:09:59 PM2/20/20
to emscripte...@googlegroups.com
Thanks Laurent! Fix in


This is a very old bug, but was never a problem in practice until we added some new globals recently, and if there are enough other imports they can overlap.

(Btw, I noticed your build script compiles serially - might be nice to use cmake or a Makefile, as that allow compiling sources in parallel, which could speed things up.)

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/119cb9f8-7c60-49e7-b60a-48271818bcc5%40googlegroups.com.

Laurent Pugin

unread,
Feb 21, 2020, 1:43:16 AM2/21/20
to emscripten-discuss
Great, thanks!

> (Btw, I noticed your build script compiles serially - might be nice to use cmake or a Makefile, as that allow compiling sources in parallel, which could speed things up.)

Thanks for the tip, I will look at it. Do you mean using emcmake cmake? Any pointers to the doc or a good example, by any chance?
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
Feb 21, 2020, 9:22:56 AM2/21/20
to emscripte...@googlegroups.com
On Thu, Feb 20, 2020 at 10:43 PM Laurent Pugin <lxp...@gmail.com> wrote:
Great, thanks!

> (Btw, I noticed your build script compiles serially - might be nice to use cmake or a Makefile, as that allow compiling sources in parallel, which could speed things up.)

Thanks for the tip, I will look at it. Do you mean using emcmake cmake? Any pointers to the doc or a good example, by any chance?


For example a simple Makefile like this:


(replacing the box2d.a with *.js and using emcc instead of AR there, to link the final executable). You can run that with emmake make -j 8 and it will use 8 cores, for example. A CMakeLists.txt file with CMake is also an option if you need more flexibility in the script.

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/6e9cba9b-9896-492e-9724-1941f38d8ab2%40googlegroups.com.

Laurent Pugin

unread,
Feb 22, 2020, 2:59:25 AM2/22/20
to emscripten-discuss
Many thanks, I will give a try.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages