Skip to content
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

Cannot compile after switching to latest emsdk... #14313

Open
Honya2000 opened this issue May 27, 2021 · 15 comments
Open

Cannot compile after switching to latest emsdk... #14313

Honya2000 opened this issue May 27, 2021 · 15 comments

Comments

@Honya2000
Copy link

Hello,

Today I installed latest emsdk and suddenly my project is not compilable anymore (previous emsdk was 2.0.13 and was perfectly working).
It complainst on unresolved symbols: __cxa_is_pointer_type, __cxa_can_catch, emscripten_is_main_browser_thread...

Do I need to link against some system libraries?
Please help, I have quite limited time...

error: undefined symbol: __cxa_is_pointer_type (referenced by $CatchInfo__deps: ['$ExceptionInfo','__cxa_is_pointer_type'], referenced by __cxa_begin_catch__deps: ['$CatchInfo','$exceptionCaught','$exception_addRef','$uncaughtExceptionCount'], referenced by top-level compiled C/C++ code)
warning: Link with -s LLD_REPORT_UNDEFINED to get more information on undefined symbols
warning: To disable errors for undefined symbols use -s ERROR_ON_UNDEFINED_SYMBOLS=0
warning: ___cxa_is_pointer_type may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __cxa_can_catch (referenced by __cxa_find_matching_catch_2__deps: ['$exceptionLast','$ExceptionInfo','$CatchInfo','__resumeException','__cxa_can_catch'], referenced by top-level compiled C/C++ code)
warning: ___cxa_can_catch may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: emscripten_is_main_browser_thread (referenced by emscripten_start_fetch__deps: ['$Fetch','$fetchXHR','$callUserCallback','emscripten_is_main_browser_thread','$runtimeKeepalivePush','$runtimeKeepalivePop','$fetchCacheData','$fetchLoadCachedData','$fetchDeleteCachedData'], referenced by top-level compiled C/C++ code)
warning: _emscripten_is_main_browser_thread may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
em++: error: 'd:/Projects/emsdk/node/12.18.1_64bit/bin/node.exe D:\Projects\emsdk\upstream\emscripten\src\compiler.js C:\Users\Andrey\AppData\Local\Temp\tmpr0zim25y.txt' failed (returned 1)
ninja: build stopped: subcommand failed.

@kripken
Copy link
Member

kripken commented May 27, 2021

Perhaps a full rebuild of your project (and emcc --clear-cache to be sure in emscripten as well) might help. That could be an old object file that uses an older form of codegen.

@Honya2000
Copy link
Author

The problem is not cmake cache or old obj / lib related.
I installed emsdk from scratch using git clone.
Rebuilded (with fresh cmake setup) all external static libs with new emsdk.
Builded main project from scratch with fresh cmake setup (without any cmake cache or other build related folders) and still have the same issues with unresolveds.
Currently I temporarily fixed this using option -s ERROR_ON_UNDEFINED_SYMBOLS=0.
But this is not the solution I want.

@Honya2000
Copy link
Author

I currently disabled exceptions by providing flag -fno-exceptions and got rid of 2 unresolveds: ___cxa_can_catch and __cxa_is_pointer_type, Not sure why I have this unresolveds with enabled exceptions though.

So currently i have only one unresolved: emscripten_is_main_browser_thread.

@sbc100
Copy link
Collaborator

sbc100 commented May 28, 2021

It looks like we could be missing some dependencies in deps_info.py.

One thing that looks suspicious is the node path in em++: error: 'd:/Projects/emsdk/node/12.18.1_64bit/bin/node.exe. emsdk was updated to use 14.15.5 back in emscripten-core/emsdk#708. So it looks like maybe your emsdk is not up-to-date? What does emcc --version say? Can you run emsdk update?

@Honya2000
Copy link
Author

Honya2000 commented Jun 2, 2021

Emcc version is correct:
emcc --version
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 2.0.23 (b15ca40)

I get emscripten_is_main_browser_thread unresolved only when I use fetch API.
When i switch to wget API instead of fetch - i don't have this unresolved anymore.

And btw seems like with new emscripten - fetch is not working anymore.
It always reports fail on asynchronous downloading.
Maybe this is related to this unresolved, which I muted.

@sbc100
Copy link
Collaborator

sbc100 commented Jun 2, 2021

Can you share the full example so that we can reproduce? If not then at least make the full output of the link command running with EMCC_DEBUG=1?

@AmauryEsparza
Copy link

I'm having the same undefined error "emscripten_is_main_browser_thread". I'm compiling in both Win and Mac and only Windows shows up the error at compilation.

Any suggestions?

@sbc100
Copy link
Collaborator

sbc100 commented Jun 22, 2021

Can you post the full command line that is failing, along with the full error message it produces?

@AmauryEsparza
Copy link

Here's an example of the command line we are using at linking. The source files are compiled separately.

emcc -m32 -s WASM=1 -s EXPORTED_RUNTIME_METHODS=["cwrap","ccall","getValue"] -s FORCE_FILESYSTEM=1 -pthread -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=1 -s TOTAL_MEMORY=512MB -s OFFSCREENCANVAS_SUPPORT=1 -s MODULARIZE=1 -s FETCH=1 -s EXPORT_NAME='MyModule' -s CASE_INSENSITIVE_FS=1 -O1 -gsource-map -s PTHREADS_DEBUG=1 *.o -o myFile.js

@sbc100
Copy link
Collaborator

sbc100 commented Jun 22, 2021

Can you also give the full output of that command, including the error message? And what version of emscripten is it failing with? When did is start failing for you? Was it working with version 2.0.13 like it was for the OP?

@AmauryEsparza
Copy link

Correct, version 2.0.13 is working fine in both platforms.

This is the error that shows up when compiling with 2.0.24 only on Windows.

error: undefined symbol: emscripten_is_main_browser_thread (referenced by emscripten_start_fetch__deps: ['$Fetch','$fetchXHR','$callUserCallback','emscripten_is_main_browser_thread','$runtimeKeepalivePush','$runtimeKeepalivePop','$fetchCacheData','$fetchLoadCachedData','$fetchDeleteCachedData'], referenced by top-level compiled C/C++ code)
warning: Link with -s LLD_REPORT_UNDEFINED to get more information on undefined symbols
warning: To disable errors for undefined symbols use -s ERROR_ON_UNDEFINED_SYMBOLS=0
warning: _emscripten_is_main_browser_thread may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library

sbc100 added a commit that referenced this issue Jun 23, 2021
The function is a little unusual in that is provided by native code in
USE_PTHREADS builds but by JS library code in non-threaded builds.

In neither case does the JS fetch code depend this symbol.  A call
to this function exists in `system/lib/fetchemscripten_fetch.cpp` but
that should be resolved using normal native->native or native->JS
linking which does not require any special handling.

See: #14313
sbc100 added a commit that referenced this issue Jun 24, 2021
The function is a little unusual in that is provided by native code in
USE_PTHREADS builds but by JS library code in non-threaded builds.

In neither case does the JS fetch code depend this symbol.  A call
to this function exists in `system/lib/fetchemscripten_fetch.cpp` but
that should be resolved using normal native->native or native->JS
linking which does not require any special handling.

See: #14313
@KeyboardDanni
Copy link

Hi, I am also running into this issue trying to compile from Rust code. For me the only unresolved symbol is __cxa_is_pointer_type.

@kripken
Copy link
Member

kripken commented Oct 19, 2021

It would be good to bisect one of these failing cases, that might be the fastest way to find the source of the regression as no other ideas have come up:

https://emscripten.org/docs/contributing/developers_guide.html#bisecting

@sbc100
Copy link
Collaborator

sbc100 commented Oct 19, 2021

__cxa_is_pointer_type is used by exception handling code. Are you linking with -s DISABLE_EXCEPTION_CATCHING=0

@KeyboardDanni
Copy link

KeyboardDanni commented Oct 19, 2021

-s DISABLE_EXCEPTION_CATCHING=0 did the trick! Thanks!

Edit: I'm not sure why setting this to 0 apparently removes the exception code (instead of uhh disabling the exception disabling, whee double negative), but hey I'll take it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants