Skip to content

Commit 0afaf41

Browse files
authored
Add documentation for feature flags and browser version flags. (#23347)
1 parent 1617598 commit 0afaf41

File tree

3 files changed

+52
-9
lines changed

3 files changed

+52
-9
lines changed

ChangeLog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ See docs/process.md for more on how version tagging works.
3131
of the target integer type, the result will be a number of the max or min value
3232
instead of a trap. This also results in a small code size improvement because
3333
of details of the LLVM IR semantics. This feature can be disabled in clang with
34-
the -mno-nontrapping-fptoint flag. (#23007)
34+
the `-mno-nontrapping-fptoint` flag. (#23007)
3535
- The `WASM_BIGINT` feature is enabled by default. This has the effect that
3636
Wasm i64 values are passed and returned between Wasm and JS as BigInt values
3737
rather than being split by Binaryen into pairs of Numbers. (#22993)
3838
- The `BULK_MEMORY` feature is enabled by default. `memory.copy` and
3939
`memory.fill` instructions are used in the implementation of C `memcpy` and
4040
`memset`, and Clang may generate them elsewhere (#22873). It can be
41-
disabled with the `-mno-bulk-memory` flag.
41+
disabled with the `-mno-bulk-memory -mno-bulk-memory-opt` flags.
4242
- When using `-sMODULARIZE` we now assert if the factory function is called with
4343
the JS `new` keyword. e.g. `a = new Module()` rather than `b = Module()`.
4444
This paves the way for marking the function as `async` which does not allow

site/source/docs/compiling/WebAssembly.rst

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,57 @@ When using ``emcc`` to build to WebAssembly, you will see a ``.wasm`` file conta
9292

9393
You may also see additional files generated, like a ``.data`` file if you are preloading files into the virtual filesystem. All that is exactly the same as when building to asm.js. One difference you may notice is the lack of a ``.mem file``, which for asm.js contains the static memory initialization data, which in WebAssembly we can pack more efficiently into the WebAssembly binary itself.
9494

95-
WebAssembly support in browsers
96-
===============================
9795

98-
WebAssembly is supported by all major browsers going back to Firefox 52, Chrome
99-
57, Safari 11 and Opera 44.
96+
WebAssembly feature extensions
97+
==============================
98+
99+
Since its original launch, WebAssembly has been expanded with various feature
100+
extensions, which have been implmented in browsers. A list of features
101+
(including already-shipped and in-progress) and details about browser versions
102+
that support them can be found on
103+
`webassembly.org <https://webassembly.org/features/>`_.
104+
105+
Several of these features can be used by Emscripten (or are by default) and can
106+
be enabled or disabled individually (using either Clang or emscripten flags)
107+
or by selecting which version of browsers Emscripten should target.
108+
109+
Examples:
110+
111+
* Exception handling (see :ref:`exceptions` for details).
112+
* SIMD (see :ref:`Porting SIMD code` for details).
113+
* Nontrapping float-to-int conversion (enabled by default, use
114+
``-mno-nontrapping-fptoint`` to disable).
115+
Clang will generate nontrapping (saturating) float-to-int conversion instructions for
116+
C typecasts. This should have no effect on programs that do not have
117+
undefined behavior but if the casted floating-point value is outside the range
118+
of the target integer type, the result will be a number of the max or min value
119+
instead of a trap. This also results in a small code size improvement because
120+
of details of the LLVM IR semantics.
121+
* Bulk memory operations (enabled by default, use
122+
``-mno-bulk-memory-opt -mno-bulk-memory`` to disable). ``memory.copy``
123+
and ``memory.fill`` instructions are used in the implementation of C
124+
``memcpy`` and ``memset``, and Clang may generate them elsewhere.
125+
* JS BigInt integration (enabled by default, use the
126+
``-sWASM_BIGINT=0`` :ref:`setting <wasm_bigint>`
127+
to disable). This has the effect that Wasm i64 values are passed and returned
128+
between Wasm and JS as BigInt values rather than being split by Binaryen into
129+
pairs of Numbers.
130+
* Sign-extension operators (enabled by default, use ``-mno-sign-ext`` to disable).
131+
132+
For the features that are enabled by default (or will be when sufficient
133+
browser support exists), it's also possible to control them by specifying
134+
which browser versions you want to target. You can use the
135+
``-sMIN_FIREFOX_VERSION`` :ref:`setting <min_firefox_version>`
136+
(and also ``MIN_CHROME_VERSION``, ``MIN_SAFARI_VERSION`` and
137+
``MIN_NODE_VERSION``). Setting a value lower than the default version will
138+
disable features not supported by the specified version. Some features (e.g.
139+
Exception handling and threads) are not enabled by default because they have
140+
tradeoffs (e.g. binary size costs or restrictions on how the resulting wasm
141+
can be used such as COEP headers). These are not controlled by the browser
142+
version flags and must be enabled explicitly.
143+
See the :ref:`settings <min_firefox_version>` page for details of the default
144+
browser versions Emscripten targets.
100145

101-
For further info on WebAssembly features supported in various browsers, see the
102-
`WebAssembly Roadmap <https://webassembly.org/roadmap/>`_
103146

104147
``.wasm`` files and compilation
105148
===============================

site/source/docs/porting/simd.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. Porting SIMD code:
1+
.. _Porting SIMD code:
22

33
.. role:: raw-html(raw)
44
:format: html

0 commit comments

Comments
 (0)