Skip to content

Commit c9844cb

Browse files
authored
bpo-40280: Add --enable-wasm-dynamic-linking (GH-32253)
1 parent 48269ea commit c9844cb

File tree

6 files changed

+194
-49
lines changed

6 files changed

+194
-49
lines changed

Doc/using/configure.rst

+26-3
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ General Options
5252
Set the Python executable suffix to *SUFFIX*.
5353

5454
The default suffix is ``.exe`` on Windows and macOS (``python.exe``
55-
executable), ``.wasm`` on Emscripten (``python.wasm`` executable), and
56-
an empty string on other platforms (``python`` executable).
55+
executable), ``.js`` on Emscripten node, ``.html`` on Emscripten browser,
56+
``.wasm`` on WASI, and an empty string on other platforms (``python``
57+
executable).
5758

5859
.. versionchanged:: 3.11
59-
The default suffix on Emscripten platform is ``.wasm``.
60+
The default suffix on WASM platform is one of ``.js``, ``.html``
61+
or ``.wasm``.
6062

6163
.. cmdoption:: --with-tzpath=<list of absolute paths separated by pathsep>
6264

@@ -141,6 +143,27 @@ General Options
141143

142144
.. versionadded:: 3.11
143145

146+
WebAssemby Options
147+
------------------
148+
149+
.. cmdoption:: --with-emscripten-target=[browser|node]
150+
151+
Set build flavor for ``wasm32-emscripten``.
152+
153+
* ``browser`` (default): preload minimal stdlib, default MEMFS.
154+
* ``node``: NODERAWFS and pthread support.
155+
156+
.. versionadded:: 3.11
157+
158+
.. cmdoption:: --enable-wasm-dynamic-linking
159+
160+
Turn on dynamic linking support for WASM.
161+
162+
Dynamic linking enables ``dlopen``. File size of the executable
163+
increases due to limited dead code elimination and additional features.
164+
165+
.. versionadded:: 3.11
166+
144167

145168
Install Options
146169
---------------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add configure option :option:`--enable-wasm-dynamic-linking` to enable
2+
``dlopen`` and MAIN_MODULE / SIDE_MODULE on ``wasm32-emscripten``.

Tools/wasm/README.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,31 @@ node --experimental-wasm-threads --experimental-wasm-bulk-memory builddir/emscri
8181

8282
## wasm32-emscripten limitations and issues
8383

84+
- Heap and stack are limited.
8485
- Most stdlib modules with a dependency on external libraries are missing:
8586
``ctypes``, ``readline``, ``sqlite3``, ``ssl``, and more.
8687
- Shared extension modules are not implemented yet. All extension modules
8788
are statically linked into the main binary.
89+
The experimental configure option ``--enable-wasm-dynamic-linking`` enables
90+
dynamic extensions.
8891
- Processes are not supported. System calls like fork, popen, and subprocess
8992
fail with ``ENOSYS`` or ``ENOSUP``.
93+
- Only ``AF_INET`` and ``AF_INET6`` with ``SOCK_STREAM`` (TCP) or
94+
``SOCK_DGRAM`` (UDP) are available. ``AF_UNIX`` is not supported.
95+
- ``socketpair`` does not work.
9096
- Blocking sockets are not available and non-blocking sockets don't work
9197
correctly, e.g. ``socket.accept`` crashes the runtime. ``gethostbyname``
9298
does not resolve to a real IP address. IPv6 is not available.
9399
- The ``select`` module is limited. ``select.select()`` crashes the runtime
94100
due to lack of exectfd support.
95-
- The ``*at`` variants of functions (e.g. ``openat``) are not available.
96-
The ``dir_fd`` argument of *os* module functions can't be used.
97101
- Signal support is limited. ``signal.alarm``, ``itimer``, ``sigaction``
98102
are not available or do not work correctly. ``SIGTERM`` exits the runtime.
99103
- Most user, group, and permission related function and modules are not
100104
supported or don't work as expected, e.g.``pwd`` module, ``grp`` module,
101-
``os.setgroups``, ``os.chown``, and so on.
105+
``os.setgroups``, ``os.chown``, and so on. ``lchown`` and `lchmod`` are
106+
not available.
107+
- ``umask`` is a no-op.
108+
- hard links (``os.link``) are not supported.
102109
- Offset and iovec I/O functions (e.g. ``os.pread``, ``os.preadv``) are not
103110
available.
104111
- ``os.mknod`` and ``os.mkfifo``
@@ -108,17 +115,9 @@ node --experimental-wasm-threads --experimental-wasm-bulk-memory builddir/emscri
108115
- ``mmap`` module is unstable. flush (``msync``) can crash the runtime.
109116
- Resource-related functions like ``os.nice`` and most functions of the
110117
``resource`` module are not available.
111-
- Some time and datetime features are broken. ``strftime`` and ``strptime``
112-
have known bugs, e.g.
113-
[%% quoting](https://github.com/emscripten-core/emscripten/issues/16155),
114-
[%U off-by-one](https://github.com/emscripten-core/emscripten/issues/16156).
115-
Extended glibc formatting features are not available.
118+
- glibc extensions for date and time formatting are not available.
116119
- ``locales`` module is affected by musl libc issues,
117120
[bpo-46390](https://bugs.python.org/issue46390).
118-
- ``uuid`` module is affected by
119-
[memory leak](https://github.com/emscripten-core/emscripten/issues/16081)
120-
and crasher in Emscripten's ``freeaddrinfo``,
121-
- Recursive ``glob`` leaks file descriptors.
122121
- Python's object allocator ``obmalloc`` is disabled by default.
123122
- ``ensurepip`` is not available.
124123

Tools/wasm/config.site-wasm32-emscripten

-4
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,3 @@ ac_cv_func_linkat=no
9191

9292
# alarm signal is not delivered, may need a callback into the event loop?
9393
ac_cv_func_alarm=no
94-
95-
# To use dlopen, you need to use Emscripten's linking support,
96-
# see https://emscripten.org/docs/compiling/Dynamic-Linking.html
97-
ac_cv_func_dlopen=no

configure

+89-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)