Skip to content

bpo-40280: Add --enable-wasm-dynamic-linking (GH-32253) #32253

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
merged 5 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ General Options
Set the Python executable suffix to *SUFFIX*.

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

.. versionchanged:: 3.11
The default suffix on Emscripten platform is ``.wasm``.
The default suffix on WASM platform is one of ``.js``, ``.html``
or ``.wasm``.

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

Expand Down Expand Up @@ -141,6 +143,27 @@ General Options

.. versionadded:: 3.11

WebAssemby Options
------------------

.. cmdoption:: --with-emscripten-target=[browser|node]

Set build flavor for ``wasm32-emscripten``.

* ``browser`` (default): preload minimal stdlib, default MEMFS.
* ``node``: NODERAWFS and pthread support.

.. versionadded:: 3.11

.. cmdoption:: --enable-wasm-dynamic-linking

Turn on dynamic linking support for WASM.

Dynamic linking enables ``dlopen``. File size of the executable
increases due to limited dead code elimination and additional features.

.. versionadded:: 3.11


Install Options
---------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add configure option :option:`--enable-wasm-dynamic-linking` to enable
``dlopen`` and MAIN_MODULE / SIDE_MODULE on ``wasm32-emscripten``.
23 changes: 11 additions & 12 deletions Tools/wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,31 @@ node --experimental-wasm-threads --experimental-wasm-bulk-memory builddir/emscri

## wasm32-emscripten limitations and issues

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

Expand Down
4 changes: 0 additions & 4 deletions Tools/wasm/config.site-wasm32-emscripten
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,3 @@ ac_cv_func_linkat=no

# alarm signal is not delivered, may need a callback into the event loop?
ac_cv_func_alarm=no

# To use dlopen, you need to use Emscripten's linking support,
# see https://emscripten.org/docs/compiling/Dynamic-Linking.html
ac_cv_func_dlopen=no
104 changes: 89 additions & 15 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading