Skip to content
Open
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
9 changes: 9 additions & 0 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,17 @@ WebAssembly options
Dynamic linking enables ``dlopen``. File size of the executable
increases due to limited dead code elimination and additional features.

On WASI 0.1 (``wasm32-wasip1``), ``python.wasm`` is linked as a
position-independent executable. It cannot run on its own: the host needs a
dynamic loader for the WebAssembly `dynamic linking convention
<https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md>`_,
which also provides ``dlopen``.

.. versionadded:: 3.11

.. versionchanged:: next
On WASI 0.1, the option links a position-independent ``python.wasm``.

.. option:: --enable-wasm-pthreads

Turn on pthreads support for WASM.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:option:`--enable-wasm-dynamic-linking` now works for WASI 0.1 without extra
linker flags: ``python.wasm`` is linked as a position-independent executable,
and ``LDSHARED`` links extension modules that a dynamic loader can load.
20 changes: 13 additions & 7 deletions configure

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

21 changes: 16 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3948,9 +3948,14 @@ then
LDCXXSHARED='$(CXX) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)'
BLDSHARED="$LDSHARED"
;;
Emscripten*|WASI*)
Emscripten*)
LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared';;
WASI*)
dnl A module's undefined symbols (the interpreter's and libc's)
dnl become imports, which the dynamic loader resolves.
LDSHARED='$(CC) -shared -Wl,--unresolved-symbols=import-dynamic'
LDCXXSHARED='$(CXX) -shared -Wl,--unresolved-symbols=import-dynamic';;
Linux*|GNU*|QNX*|VxWorks*|Haiku*)
LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared';;
Expand Down Expand Up @@ -3981,10 +3986,6 @@ then
NetBSD*|DragonFly*)
LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared';;
WASI*)
AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [
dnl not implemented yet
]);;
CYGWIN*)
LDSHARED='$(CC) -shared -Wl,--enable-auto-image-base'
LDCXXSHARED='$(CXX) -shared -Wl,--enable-auto-image-base';;
Expand Down Expand Up @@ -4083,6 +4084,16 @@ then
then
LINKFORSHARED="-Wl,--export-dynamic"
fi;;
WASI*)
dnl Link python.wasm as a position-independent executable that
dnl shares its memory with the modules it loads and exports its
dnl symbols to them. main() is exported by name because libc.so
dnl calls it and CPython is compiled with hidden visibility.
dnl Only for WASI 0.1: later versions link a component instead.
AS_CASE([$enable_wasm_dynamic_linking/$host],
[yes/*-wasi|yes/*-wasip1*], [
LINKFORSHARED="-Wl,-pie -Wl,--import-memory -Wl,--export-dynamic -Wl,--export=__main_argc_argv"
]);;
SunOS/5*) if test "$ac_cv_gcc_compat" = "yes"; then
if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
then
Expand Down
Loading