@@ -35,7 +35,13 @@ docker run --rm -ti -v $(pwd):/python-wasm/cpython -w /python-wasm/cpython quay.
35
35
36
36
### Compile a build Python interpreter
37
37
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:
39
45
40
46
``` shell
41
47
mkdir -p builddir/build
@@ -45,13 +51,13 @@ make -j$(nproc)
45
51
popd
46
52
```
47
53
48
- ### Fetch and build additional emscripten ports
54
+ ### Cross-compile to wasm32- emscripten for browser
49
55
50
56
``` shell
51
- embuilder build zlib bzip2
57
+ ./Tools/wasm/wasm_build.py emscripten-browser
52
58
```
53
59
54
- ### Cross compile to wasm32-emscripten for browser
60
+ The command is roughly equivalent to:
55
61
56
62
``` shell
57
63
mkdir -p builddir/emscripten-browser
@@ -85,22 +91,29 @@ and header files with debug builds.
85
91
### Cross compile to wasm32-emscripten for node
86
92
87
93
``` 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
90
102
91
103
CONFIG_SITE=../../Tools/wasm/config.site-wasm32-emscripten \
92
104
emconfigure ../../configure -C \
93
105
--host=wasm32-unknown-emscripten \
94
106
--build=$( ../../config.guess) \
95
107
--with-emscripten-target=node \
108
+ --enable-wasm-dynamic-linking \
96
109
--with-build-python=$( pwd) /../build/python
97
110
98
111
emmake make -j$( nproc)
99
112
popd
100
113
```
101
114
102
115
``` 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
104
117
```
105
118
106
119
(`` --experimental-wasm-bigint `` is not needed with recent NodeJS versions)
@@ -199,6 +212,15 @@ Node builds use ``NODERAWFS``.
199
212
- Node RawFS allows direct access to the host file system without need to
200
213
perform `` FS.mount() `` call.
201
214
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
+
202
224
# Hosting Python WASM builds
203
225
204
226
The 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
234
256
`` pkg-config `` overrides. The script assumes that WASI-SDK is installed in
235
257
`` /opt/wasi-sdk `` or `` $WASI_SDK_PATH `` .
236
258
259
+ ``` shell
260
+ ./Tools/wasm/wasm_build.py wasi
261
+ ```
262
+
263
+ The command is roughly equivalent to:
264
+
237
265
``` shell
238
266
mkdir -p builddir/wasi
239
267
pushd builddir/wasi
0 commit comments