Issues with LLVM WebAssembly Backend (LLVM 8.0.0)

551 views
Skip to first unread message

Chuck H

unread,
Apr 4, 2019, 4:00:46 AM4/4/19
to emscripten-discuss
Hi, 

I am new to Emscripten and currently I am trying to use LLVM WebAssembly Backend in the Emscripting following the tutorial https://emscripten.org/docs/compiling/WebAssembly.html 
However, when I run the command "emcc tests/hello_world.cpp -o test.html" on Windows, I get this warning "shared:WARNING: LLVM version appears incorrect (seeing "8.0", expected "9.0")".
Moreover, when I open the test.html, the following errors appear in the webpage:

both async and sync fetching of the wasm failed
abort("both async and sync fetching of the wasm failed") at Error
    at jsStackTrace (file:///C:/Users/Desktop/test/emsdk/emscripten/1.38.30/test.js:1140:13)
    at stackTrace (file:///C:/Users/Desktop/test/emsdk/emscripten/1.38.30/test.js:1157:12)
    at abort (file:///C:/Users/Desktop/test/emsdk/emscripten/1.38.30/test.js:2453:44)
    at getBinary (file:///C:/Users/Desktop/test/emsdk/emscripten/1.38.30/test.js:1573:5)
    at file:///C:/Users/Desktop/test/emsdk/emscripten/1.38.30/test.js:1587:14 

So what is the issue here? is it because I am using LLVM 8.0.0?

praveer kumar

unread,
Apr 4, 2019, 8:04:44 AM4/4/19
to emscripte...@googlegroups.com
Hi Chuck H,
It worked for me. 
below are the steps I followed:
1> go to https://github.com/emscripten-core/emscripten/releases and download 1.38.30.zip(if you want to work on windows os)
2> unzip it.
3>  open the command prompt and navigate to the directory where you have emcc.
4>then type "emcc tests/hello_world.cpp -o tests/hello_world.html" command.
5> you will find below files in the tests directory:
hello_world.wasm
hello_world.js
hello_world.html
6> in the same command prompt you type start[it will start another command promt]
7> in the new command prompt you type below command "emrun --no_browser --port 9090 ."
8> now go to the browser and in the address bar type "http://localhost:9090/hello_world.html
you will get your output.
I have attached a snapshot for your reference as well.

if I didn't misunderstand your question then this is what you are expecting.
below article might be useful for you 


--
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.
For more options, visit https://groups.google.com/d/optout.
simple_steps.jpg

Floh

unread,
Apr 4, 2019, 8:34:41 AM4/4/19
to emscripten-discuss
This procedure will currently still use emscripten's custom "fastcomp" llvm backend, not the new "official" WebAssembly backend which is now part of upstream clang since version 8.0.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Floh

unread,
Apr 4, 2019, 8:53:27 AM4/4/19
to emscripten-discuss
I'm seeing the same messages on macOS (but I'm getting a runnable program, despite the error messages), here's what I'm doing:

- install the standard llvm 8.0 toolchain with 'brew install llvm'
- change LLVM_ROOT in .emscripten to LLVM_ROOT='/usr/local/opt/llvm/bin'
- from here on as usual...

The cmake generation phase seems to work, cmakes test-compiles for compiler-detection work, and it is picking up the right compiler:

-- The C compiler identification is Clang 8.0.0
-- The CXX compiler identification is Clang 8.0.0

...but when compiling the project I'm getting the same messages:

shared:WARNING: LLVM version appears incorrect (seeing "8.0", expected "9.0")

...and later when linking it doesn't find my EM_JS() functions, e.g.:

error: undefined symbol: _sapp_js_create_textfield
error: undefined symbol: _sapp_js_focus_textfield
error: undefined symbol: _sapp_js_unfocus_textfield

Switching off ERROR_ON_UNDEFINED_SYMBOLS I'm getting a running program out of this however (those JS functions aren't actually called in the simple "Hello Triangle" program I'm testing).

-Floh.

Floh

unread,
Apr 4, 2019, 9:10:48 AM4/4/19
to emscripten-discuss
Found the culprit for the warning:


def expected_llvm_version():
  if get_llvm_target() == WASM_TARGET:
    return "9.0"
  else:
    return "6.0"

In the one place where this is called, the return value is ignored, so I guess the warning can be ignored.

Not sure about the other problems though, for my missing JS functions, I guess the EM_JS() mechanism hasn't been fixed yet for the clang backend, and I can't reproduce the loading problems you're seeing.

However: maybe you should try the "emrun" method for testing, this opens a local webserver:


...thinking about it, this is most likely the problem. E.g. double-clicking the .html file definitely doesn't work for running .wasm applications.

Cheers,
-Floh.

Alon Zakai

unread,
Apr 4, 2019, 11:56:49 AM4/4/19
to emscripte...@googlegroups.com
The warning about 8 vs 9 may be important - recent emscripten is developed against recent LLVM. So if it assumes LLVM 9 (currently in prerelease) it may well fail without that.

However, that error may be something else. Was there nothing else in the web console? It should say why it failed to fetch either async or sync. (For example, if the browser lacks wasm support, it should say that.)

Building LLVM from latest git or svn is best. Or you can download a build from one of the green runs on the wasm waterfall, https://ci.chromium.org/p/wasm/builders For linux, you can also use the emsdk with   ./emsdk install latest-upstream   We hope to get other platforms working soon - that's actually the last major blocker before we officially start recommending people test the LLVM wasm backend (since feature-wise it's very close to what we need, and perf-wise it is better than fastcomp now).

- Alon


--
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.
Reply all
Reply to author
Forward
0 new messages