-
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
Using the closure compiler at link time corrupts references to variables in EM_JS blocks #21748
Comments
For code that lives inside the module itself I you probably just want to use Is this a recent regression? We did recently stop exporting |
I'm not running in strict mode, so I don't think it qualifies as a regression. If I've misunderstood, let me know and I'll test the repro with a version < 3.1.55. Removing the |
I don't use Closure, but I think if you use |
If you access a property of the Better to just use Closing this for now as WAI. |
Please include the following in your bug report:
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.57 (1df9c19)
clang version 19.0.0git (https:/github.com/llvm/llvm-project ccdebbae4d77d3efc236af92c22941de5d437e01)
Target: wasm32-unknown-emscripten
Thread model: posix
Compiling with
--closure=1
causes variables to be renamed at access time that are attached toModule
. For instance,Module.HEAPU8
becomes undefined. This happens regardless of whetherMODULARIZE
is used. This happens regardless of the-O
setting passed to the linker or compiler.The following code prints an error when
--closure=1
is used:I have prepared a minimal repro case at https://github.com/mlabbe/closure-bug . The README contains steps to reproduce the bug.
In addition to the bug proper, I have a couple of ancillary notes/questions:
The official docs on using closure state "Closure is only run if JavaScript opts are being done (-O2 or above)." However, I was able to have Closure run if I passed -O0 to the linker, or didn't specify -O at all. Some minification occurred, but not all, as if I passed -O3. So these docs do not appear to be accurate.
Here is the relevant part of the output from
emcc -v
:The text was updated successfully, but these errors were encountered: