Skip to content

Commit

Permalink
[docs] Update docs on closure to match current behavior.
Browse files Browse the repository at this point in the history
Closure is not automatically run in -O3 by default.
  • Loading branch information
brendandahl committed Dec 12, 2024
1 parent 1171ada commit 66adcba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
5 changes: 1 addition & 4 deletions docs/emcc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ Options that are modified or new in *emcc* are listed below:
"--closure 0|1|2"
[link] Runs the *Closure Compiler*. Possible values are:

* "0": No closure compiler (default in "-O2" and below).
* "0": No closure compiler (default).

* "1": Run closure compiler. This greatly reduces the size of
the support JavaScript code (everything but the WebAssembly or
Expand All @@ -277,9 +277,6 @@ Options that are modified or new in *emcc* are listed below:
before the closure-compiled code runs, because then it will
reuse that variable.

* Closure is only run if JavaScript opts are being done ("-O2" or
above).

"--closure-args=<args>"
[link] Pass arguments to the *Closure compiler*. This is an
alternative to "EMCC_CLOSURE_ARGS".
Expand Down
3 changes: 1 addition & 2 deletions site/source/docs/tools_reference/emcc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,14 @@ Options that are modified or new in *emcc* are listed below:
[link]
Runs the :term:`Closure Compiler`. Possible values are:

- ``0``: No closure compiler (default in ``-O2`` and below).
- ``0``: No closure compiler (default).
- ``1``: Run closure compiler. This greatly reduces the size of the support JavaScript code (everything but the WebAssembly or asm.js). Note that this increases compile time significantly.
- ``2``: Run closure compiler on *all* the emitted code, even on **asm.js** output in **asm.js** mode. This can further reduce code size, but does prevent a significant amount of **asm.js** optimizations, so it is not recommended unless you want to reduce code size at all costs.

.. note::

- Consider using ``-sMODULARIZE`` when using closure, as it minifies globals to names that might conflict with others in the global scope. ``MODULARIZE`` puts all the output into a function (see ``src/settings.js``).
- Closure will minify the name of `Module` itself, by default! Using ``MODULARIZE`` will solve that as well. Another solution is to make sure a global variable called `Module` already exists before the closure-compiled code runs, because then it will reuse that variable.
- Closure is only run if JavaScript opts are being done (``-O2`` or above).

``--closure-args=<args>``
[link]
Expand Down

0 comments on commit 66adcba

Please sign in to comment.