@@ -35,7 +35,13 @@ docker run --rm -ti -v $(pwd):/python-wasm/cpython -w /python-wasm/cpython quay.
3535
3636### Compile a build Python interpreter
3737
38- From within the container, run the following commands:
38+ From within the container, run the following command:
39+
40+ ``` shell
41+ ./Tools/wasm/wasm_build.py build
42+ ```
43+
44+ The command is roughly equivalent to:
3945
4046``` shell
4147mkdir -p builddir/build
@@ -45,13 +51,13 @@ make -j$(nproc)
4551popd
4652```
4753
48- ### Fetch and build additional emscripten ports
54+ ### Cross-compile to wasm32- emscripten for browser
4955
5056``` shell
51- embuilder build zlib bzip2
57+ ./Tools/wasm/wasm_build.py emscripten-browser
5258```
5359
54- ### Cross compile to wasm32-emscripten for browser
60+ The command is roughly equivalent to:
5561
5662``` shell
5763mkdir -p builddir/emscripten-browser
@@ -85,22 +91,29 @@ and header files with debug builds.
8591### Cross compile to wasm32-emscripten for node
8692
8793``` shell
88- mkdir -p builddir/emscripten-node
89- pushd builddir/emscripten-node
94+ ./Tools/wasm/wasm_build.py emscripten-browser-dl
95+ ```
96+
97+ The command is roughly equivalent to:
98+
99+ ``` shell
100+ mkdir -p builddir/emscripten-node-dl
101+ pushd builddir/emscripten-node-dl
90102
91103CONFIG_SITE=../../Tools/wasm/config.site-wasm32-emscripten \
92104 emconfigure ../../configure -C \
93105 --host=wasm32-unknown-emscripten \
94106 --build=$( ../../config.guess) \
95107 --with-emscripten-target=node \
108+ --enable-wasm-dynamic-linking \
96109 --with-build-python=$( pwd) /../build/python
97110
98111emmake make -j$( nproc)
99112popd
100113```
101114
102115``` shell
103- node --experimental-wasm-threads --experimental-wasm-bulk-memory --experimental-wasm-bigint builddir/emscripten-node/python.js
116+ node --experimental-wasm-threads --experimental-wasm-bulk-memory --experimental-wasm-bigint builddir/emscripten-node-dl /python.js
104117```
105118
106119(`` --experimental-wasm-bigint `` is not needed with recent NodeJS versions)
@@ -199,6 +212,15 @@ Node builds use ``NODERAWFS``.
199212- Node RawFS allows direct access to the host file system without need to
200213 perform `` FS.mount() `` call.
201214
215+ ## wasm64-emscripten
216+
217+ - wasm64 requires recent NodeJS and `` --experimental-wasm-memory64 `` .
218+ - `` EM_JS `` functions must return `` BigInt() `` .
219+ - `` Py_BuildValue() `` format strings must match size of types. Confusing 32
220+ and 64 bits types leads to memory corruption, see
221+ [ gh-95876 ] ( https://github.com/python/cpython/issues/95876 ) and
222+ [ gh-95878 ] ( https://github.com/python/cpython/issues/95878 ) .
223+
202224# Hosting Python WASM builds
203225
204226The simple REPL terminal uses SharedArrayBuffer. For security reasons
@@ -234,6 +256,12 @@ The script ``wasi-env`` sets necessary compiler and linker flags as well as
234256`` pkg-config `` overrides. The script assumes that WASI-SDK is installed in
235257`` /opt/wasi-sdk `` or `` $WASI_SDK_PATH `` .
236258
259+ ``` shell
260+ ./Tools/wasm/wasm_build.py wasi
261+ ```
262+
263+ The command is roughly equivalent to:
264+
237265``` shell
238266mkdir -p builddir/wasi
239267pushd builddir/wasi
0 commit comments