-
Notifications
You must be signed in to change notification settings - Fork 574
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
What is the difference between clang and em++? #3277
Comments
Hi, you are using |
Thank you for your reply! I tried using clang++,But it ditn't work still. still the same error. |
What if you try to remove |
The errors you get seem to be from exception related imports that cannot be resolvedas the runtime does not provide the required imports for the module. If you look at the readme on wasi-sdk main page you can see that it does not support exceptions. Also note that since the exceptions come from std, using nostdlib will possibly make the missing classes into imports that then fail as you try to run the program.
So you could try including the Emscripten by default does not support exceptions either. However, it will allow the code to compile and run. It will abort the entire program when an exception occurs by default. The docs say that there is some kind of support possible, but I never got it to work (tried for few hours to get lua to compile to wasm with exceptions or longjmp). |
I compiled the libjsoncpp.a library using Emscripten. When I tried to compile wasm using clang and linked this library, it resulted in errors at runtime.
cmd:
clang -O3 -nostdlib \ -pthread \ -Wl,--shared-memory,--max-memory=131072 \ -o test.wasm test.cpp ./lib/libjsoncpp.a \ -Wl,--export=init -Wl,--export=onMessage \ -Wl,--export=__heap_base -Wl,--export=__data_end \ -Wl,--no-entry -Wl,--strip-all -Wl,--allow-undefined
err:
warning: failed to link import function (env, _Znwm)
warning: failed to link import function (env, _ZdlPv)
warning: failed to link import function (env, _ZNSt12length_errorD1Ev)
warning: failed to link import function (env, _ZNSt11logic_errorC2EPKc)
warning: failed to link import function (env, _ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm)
However, when I compiled the wasm using em++, it could parse JSON correctly at runtime.
cmd:
em++ -g -O3 test.cpp lib/libjsoncpp.a -o test.wasm --no-entry -s WASM=1 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s EXPORTED_FUNCTIONS=_init,_onMessage
result:
Is it because clang uses wasi-sdk, while em++ uses Emscripten? Does wasi-sdk not support jsoncpp?
How to solve? Thank you!
The text was updated successfully, but these errors were encountered: