-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
ERROR_ON_UNDEFINED_SYMBOLS=1 always passed for emcc effectively prevents any dynamic linking #41750
Comments
@NikVolf actually you can override emcc arguments with help of export EMMAKEN_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0"
rustc --target=wasm32-unknown-emscripten main.rs |
Thank you for this, it saved me so much time. [target.wasm32-unknown-emscripten]
rustflags = [
"-C", "link-args=--no-entry",
"-C", "link-args=-s",
"-C", "link-args=ERROR_ON_UNDEFINED_SYMBOLS=0" ] but they ended up being overriden. |
As far as I know wasm32 targets by default do not support dynamic linking as there is no dynamic linker available on the platform. Ignoring error on undefined symbols may lead to hard to find runtime errors. This is a chapter from emscripten doc about dynamic linking, are you sure you really want to use the experimental dynamic linking? Dynamic linking Emscripten’s goal is to generate the fastest and smallest possible code, and for that reason it focuses on generating a single JavaScript file for an entire project. For that reason, dynamic linking should be avoided when possible. By default, Emscripten .so files are the same as regular .o object files. Dynamic libraries that you specify in the final build stage (when generating JavaScript or HTML) are linked in as static libraries. Emcc ignores commands to dynamically link libraries during the compile stage (i.e., not in the final build stage). This is to ensure that the same dynamic library is not linked multiple times in intermediate build stages, which would result in duplicate symbol errors. There is experimental support for true dynamic libraries, loaded as runtime, either via dlopen or as a shared library. See that link [https://github.com/emscripten-core/emscripten/wiki/Linking] for the details and limitations. |
I think this issue has been fixed in Emscripten. Anything you want to add @sbc100? |
|
The author asserts that there is an incompatibility between |
Its true that most users don't want But emcc will take care of setting the default value of |
Okay so while we are using the current stable Rust which does explicitly invoke emcc with |
Indeed. But I guess this bug should still be marked as fixed? (since it is now fixed as HEAD, and no further action is planned/needed). |
Thank you! This does indeed seem to be fixed, or if there is a problem still, it probably is better covered by another issue, so I am closing this! |
the following rust code is failing to compile using wasm32-unknown-emscripten target
with
correct me if I'm wrong, I might be terrible wrong with this, but
#[link]
withoutkind=static
implies dynamic linking, and the above code should not fail to compile?As for emscripten itself, it has no problem compiling C code like this:
with
emcc <source above.c> -O3 -s WASM=1 -s SIDE_MODULE=1 -o result.wasm
producing nice import entry in the result.wasm
So, the question is, is there is any option to have dynamic symbols in the resulting wasm? Or at least override this linker
ERROR_ON_UNDEFINED_SYMBOLS
argument at some point?source link would be:
rust/src/librustc_back/target/wasm32_unknown_emscripten.rs
Line 21 in ec27aa9
The text was updated successfully, but these errors were encountered: