-
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
SIDE_MODULE imports increases dramatically after 2.0.32 #15487
Comments
Bisecting might help here, that can be pretty fast to do: https://emscripten.org/docs/contributing/developers_guide.html#bisecting |
Do you have a delta of the exports? What kinds of symbols are in the delta? Are they symbols from archive.a? Are you using SIDE_MODULE=1 or SIDE_MODULE=2? Can you share the full emcc link command? BTW, there is the change in 2.0.34 that should limit the exports of SIDE_MODULE=1/MAIN_MODULE=1: #15413 |
yes they are symbols from archive.a which its trying to import.
we are using SIDE_MODULE=2 the last working version was |
This is the emcc command being used.
hmm does that mean that there are plans to deprecate SIDE_MODULE=2 ? |
If you are using Since I don't see |
right we use |
If you specify you export in Can you see if maybe the new symbols are both imported and exported? (imported via GOT.mem or GOT.func modules and exported directly). If that is the case, that could explain the increase.. these are dynamic symbols that are defined in the side module but can be overridden from by main module. If that is the case, I think we can find a solution where these symbols are instead internalized within the side module (as they previously were). |
@sbc100 @kripken using bisect this is the release where it first occured, its an llvm change. and this looks suspicious. when looking at the archive which i have i see that most if not all of the functions which are being imported are of type |
I think capital "W" means that symbols defined weakly in the archive. When a symbol is weakly defined like that it means it can be overridden by a strongly defined symbol, either at static link time or at dynamic link time. For side modules that means that module must both import and export the symbol. In most cases the thing that is exported will then be re-imports, assuming that not other module defines that symbol. Do you know why you are archive contains so many weakly defined symbols? |
in 1 of the side modules we pack opencv in, exporting only a small set of functions to expose functionality we need and to keep the size of the side module small. some parts of the list of imports are below.
|
Ah, I see. I guess C++ using a lot of weak symbols and in a dynamically linked setup the linker doesn't know which shared library is going to define a given symbol, so it has to both import and export them. However if you know for sure that all the symbol in a shared library are not going to be overridden by any other we should have link flag to allow you to specify this. I think perhaps |
I an confirm that this commit below is the one causing the issue. |
i couldnt find any reference to this, not sure if this is something i can try out. |
Yes, I would like to have the old behaviour somehow, at least as an option. I just need to find a set of wasm-ld flags we can use to enable this behaviour. |
Hi Sam, would you still be working on this? I dont think we can upgrade to later versions if this issue is still there |
Yes this is certainly something that needs fixing. I haven't had a chance to look into it yet. |
@sbc100 Happy New Year to you! |
… libraries We have some special handling for weakly defined symbols where we both import and export them, but this is not needed for hidden symbols which should never be imported or exported. See emscripten-core/emscripten#16972 This should also help with: emscripten-core/emscripten#15487 Differential Revision: https://reviews.llvm.org/D126491
I think this llvm change might help a lot with this: https://reviews.llvm.org/D126491 |
It looks like that LLVM commit landed. I'm just curious if there are plans to fix this issue now, or if there are other blockers. Thank you! |
… libraries We have some special handling for weakly defined symbols where we both import and export them, but this is not needed for hidden symbols which should never be imported or exported. See emscripten-core/emscripten#16972 This should also help with: emscripten-core/emscripten#15487 Differential Revision: https://reviews.llvm.org/D126491
@sbc100 Continuing from the issue from the op, using these, it brought our imports to within the browser's limit.:
However we are still importing way more functions as compared to before. The reason is because the weak symbols in our side module are mostly of default visibility, so according to the logic in https://github.com/llvm/llvm-project/blob/main/lld/wasm/Writer.cpp#L725, it will get imported. Our side module comes from a third party vendor, besides getting them to compile their library with |
Apologies, I was still testing on 3.1.16. |
Not that I know of. We still compiler with Lines 955 to 960 in 1b26bf5
|
Update: Seems like the issue has not been resolved. Although part of it is resolved in my sample app, I'm still seeing the explosion of imports in my build. I believe we can close this chapter in emscripten. Thank you. Edit: Opps I cant close it because I'm not the OP |
Did you mean to say that your vendor compiled their library with |
Yes, exactly. Thanks for pointing out. I've edit the previous comment to reflect it correctly |
To reduce the number of exports in the side modules. See: emscripten-core/emscripten#15487 (comment)
UPDATE: last good version is
2.0.27
We are upgrading from 2.0.26 to 2.0.32 and the side modules are failing to compile in browser because they exceed the import limit of 100000, in fact it grew from 4662 to 141035.
symptom as follows
it seems that something inside wasm-ld changed and is causing this.
I am trying to get the in between versions of emsdk to narrow down the version, in the mean time would like to ask if anyone has any ideas
both 2.0.26 and 2.0.32 have flags as follows
The text was updated successfully, but these errors were encountered: