-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
How to use system library source code files provided by emscripten ? #17638
Comments
Is this a emscripten bug? Anyone can help? |
Emscripten doesn't support any of those system calls. We should probably remove that header completely from our system. The networking support in emscripten has some fairly significant limitations due to the way the web platform is designed. See https://emscripten.org/docs/porting/networking.html for more on this |
We don't implement any of the functions declared in these headers, so there is not real use them, and I think it can be misleading to allow them to be included at compile time. See #17638
We don't implement any of the functions declared in these headers, so there is not real use them, and I think it can be misleading to allow them to be included at compile time. See #17638
We don't implement any of the functions declared in these headers, so there is not real use them, and I think it can be misleading to allow them to be included at compile time. See #17638
We don't implement any of the functions declared in these headers, so there is not real use them, and I think it can be misleading to allow them to be included at compile time. See #17638
We don't implement any of the functions declared in these headers, so there is not real use them, and I think it can be misleading to allow them to be included at compile time. See #17638
Do you only remove some linux-specific musl headers #17704 ? |
Right now for linux-specific source files we just exclude from the build. So they should not effect any users. Unless I'm missing something? |
Hopefully this issue can now be closed? If you |
It seems like this can be closed |
The question is: How to use system library source code files provided by emscripten, for example: https://github.com/emscripten-core/emscripten/blob/main/system/lib/libc/musl/src/linux/epoll.c ?
When I compile a c/c++ project (i.e. an example code at https://github.com/uNetworking/uSockets) to WASM, erros occured as following:
......
[ 85%] Built target uSockets
[ 92%] Building C object CMakeFiles/httpServer.dir/http_server.c.o
[100%] Linking C executable httpServer.js
error: undefined symbol: epoll_create1 (referenced by top-level compiled C/C++ code)
warning: Link with -sLLD_REPORT_UNDEFINED to get more information on undefined symbols
warning: To disable errors for undefined symbols use -sERROR_ON_UNDEFINED_SYMBOLS=0
warning: _epoll_create1 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: epoll_ctl (referenced by top-level compiled C/C++ code)
warning: _epoll_ctl may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: epoll_wait (referenced by top-level compiled C/C++ code)
warning: _epoll_wait may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: eventfd (referenced by top-level compiled C/C++ code)
warning: _eventfd may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: timerfd_create (referenced by top-level compiled C/C++ code)
warning: _timerfd_create may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: timerfd_settime (referenced by top-level compiled C/C++ code)
warning: _timerfd_settime may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
emcc: error: '/home/dev_tools/emsdk/node/14.18.2_64bit/bin/node /home/dev_tools/emsdk/upstream/emscripten/src/compiler.js /tmp/tmpqx7zx6d7.json' failed (returned 1)
make[2]: *** [CMakeFiles/httpServer.dir/build.make:101: httpServer.js] Error 1
make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/httpServer.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
emmake: error: 'make' failed (returned 2)
I searched the undefined symbols, such as epoll_create1, epoll_wait, epoll_ctl, etc., and found that they are in the file epoll.h, which is located at : /home/dev_tools/emsdk/upstream/emscripten/cache/sysroot/include/sys/epoll.h,
whose functions are defined in: /home/dev_tools/emsdk/upstream/emscripten/system/lib/libc/musl/src/linux/epoll.c. This code file belongs to a system library libc provided by emscripten.
Even I add these function names into EXPORTED_FUNCTIONS by target_link_options(httpServer PRIVATE -sLINKABLE=1) in CMakeLists, the erros are the same.
The guidance "How do I link against system libraries ..." (https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-link-against-system-libraries-like-sdl-boost-etc) says : System libraries that are included with Emscripten are automatically linked when you compile (just the necessary parts). This includes libc, libc++ (C++ standard library) and SDL.
So, why do the errors occur with undefined symbols,. e.g. epoll_create1, epoll_wait, epoll_ctl, etc. ?
Do I need to explicitly and manually add all source code files provided by emscripten ( e.g. in the libc library) when I build a c/c++ program/library into WASM ?
How can I fix this issue ?
I appreciate an early reply and comments. Thanks.
The text was updated successfully, but these errors were encountered: