-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[js-compiler] Remove special handling for JS library aliases. NFC #25441
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sbc100
added a commit
to sbc100/emscripten
that referenced
this pull request
Oct 2, 2025
This change remove some special casing in `addFromLibrary` which simplifies the code, and also lays the groundwork for emscripten-core#25441 which explicitly allows JS symbol to alias native ones. This special handling was added in emscripten-core#19046 in order to deal with case where `glXXX` symbols were simultaneously aliased by `emscripten_glXX` and exported (in the case of MAIN_MODULE=1). However, this work is no longer needed since in emscripten-core#21785 we stopped stopped included symbol exported due to `MAIN_MODULE=1` as part of WASM_EXPORT (the symbols are only exported to side modules, not to JS). In original problem was that `emscripten_glXX` should always points to the original JS implementation, even if a native version is exported. Just in case somebody is explicitly exporting these symbols this change also flips the aliases such that the `glXX` functions are now aliases of `emscripten_glXX` and not the other way around. This means that exporting `glXXX` will replace/override the alias, but will not effect `emscripten_glXX`.
e9af1c3 to
bf52815
Compare
Collaborator
Author
|
Sorry for the long explanation, its quite a simple fix for a rather complex problem. |
kripken
approved these changes
Oct 2, 2025
src/lib/libwebgl.js
Outdated
| // | ||
| // We do this by renaming `glX` symbols to `emscripten_glX` and then setting | ||
| // `glX` as an alias of `emscripten_glX`. The reason for this renaming is to | ||
| // ensure that `emscripten_glX` is always available, even in cases were native |
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
| // ensure that `emscripten_glX` is always available, even in cases were native | |
| // ensure that `emscripten_glX` is always available, even in cases where native |
bf52815 to
7e07047
Compare
sbc100
added a commit
to sbc100/emscripten
that referenced
this pull request
Oct 2, 2025
This change remove some special casing in `addFromLibrary` which simplifies the code, and also lays the groundwork for emscripten-core#25441 which explicitly allows JS symbol to alias native ones. This special handling was added in emscripten-core#19046 in order to deal with case where `glXXX` symbols were simultaneously aliased by `emscripten_glXX` and exported (in the case of MAIN_MODULE=1). However, this work is no longer needed since in emscripten-core#21785 we stopped stopped included symbol exported due to `MAIN_MODULE=1` as part of WASM_EXPORT (the symbols are only exported to side modules, not to JS). In original problem was that `emscripten_glXX` should always points to the original JS implementation, even if a native version is exported. Just in case somebody is explicitly exporting these symbols this change also flips the aliases such that the `glXX` functions are now aliases of `emscripten_glXX` and not the other way around. This means that exporting `glXXX` will replace/override the alias, but will not effect `emscripten_glXX`.
This change remove some special casing in `addFromLibrary` which simplifies the code, and also lays the groundwork for emscripten-core#25441 which explicitly allows JS symbol to alias native ones. This special handling was added in emscripten-core#19046 in order to deal with case where `glXXX` symbols were simultaneously aliased by `emscripten_glXX` and exported (in the case of MAIN_MODULE=1). However, this work is no longer needed since in emscripten-core#21785 we stopped stopped included symbol exported due to `MAIN_MODULE=1` as part of WASM_EXPORT (the symbols are only exported to side modules, not to JS). In original problem was that `emscripten_glXX` should always points to the original JS implementation, even if a native version is exported. Just in case somebody is explicitly exporting these symbols this change also flips the aliases such that the `glXX` functions are now aliases of `emscripten_glXX` and not the other way around. This means that exporting `glXXX` will replace/override the alias, but will not effect `emscripten_glXX`.
7e07047 to
3900dfd
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change remove some special casing in
addFromLibrarywhichsimplifies the code, and also lays the groundwork for #25441 which
explicitly allows JS symbol to alias native ones.
This special handling was added in #19046 in order to deal with case
where
glXXXsymbols were simultaneously aliased byemscripten_glXXand exported (in the case of MAIN_MODULE=1).
However, this work is no longer needed since in #21785 we stopped
stopped included symbol exported due to
MAIN_MODULE=1as part ofWASM_EXPORTS(the symbols are only exported to side modules, not toJS).
In original problem was that
emscripten_glXXshould always points tothe original JS implementation, even if a native version is exported.
Just in case somebody is explicitly exporting these symbols this change
also flips the aliases such that the
glXXfunctions are now aliases ofemscripten_glXXand not the other way around. This means thatexporting
glXXXwill replace/override the alias, but will not effectemscripten_glXX.