69
69
```
70
70
71
71
Serve ` python.html ` with a local webserver and open the file in a browser.
72
-
73
- ``` shell
74
- emrun builddir/emscripten-browser/python.html
75
- ```
76
-
77
- or
72
+ Python comes with a minimal web server script that sets necessary HTTP
73
+ headers like COOP, COEP, and mimetypes. Run the script outside the container
74
+ and from the root of the CPython checkout.
78
75
79
76
``` shell
80
77
./Tools/wasm/wasm_webserver.py
@@ -84,6 +81,7 @@ and open http://localhost:8000/builddir/emscripten-browser/python.html . This
84
81
directory structure enables the * C/C++ DevTools Support (DWARF)* to load C
85
82
and header files with debug builds.
86
83
84
+
87
85
### Cross compile to wasm32-emscripten for node
88
86
89
87
``` shell
@@ -232,6 +230,28 @@ WASI builds require [WASI SDK](https://github.com/WebAssembly/wasi-sdk) 15.0+
232
230
and currently [ wasix] ( https://github.com/singlestore-labs/wasix ) for POSIX
233
231
compatibility stubs.
234
232
233
+ ## Cross-compile to wasm32-wasi
234
+
235
+ The script `` wasi-env `` sets necessary compiler and linker flags as well as
236
+ `` pkg-config `` overrides. The script assumes that WASI-SDK is installed in
237
+ `` /opt/wasi-sdk `` or `` $WASI_SDK_PATH `` .
238
+
239
+ ``` shell
240
+ mkdir -p builddir/wasi
241
+ pushd builddir/wasi
242
+
243
+ CONFIG_SITE=../../Tools/wasm/config.site-wasm32-wasi \
244
+ CFLAGS=" -isystem /opt/wasix/include" \
245
+ LDFLAGS=" -L/opt/wasix/lib -lwasix" \
246
+ ../../Tools/wasm/wasi-env ../../configure -C \
247
+ --host=wasm32-unknown-wasi \
248
+ --build=$( ../../config.guess) \
249
+ --with-build-python=$( pwd) /../build/python
250
+
251
+ make -j$( nproc)
252
+ popd
253
+ ```
254
+
235
255
## WASI limitations and issues (WASI SDK 15.0)
236
256
237
257
A lot of Emscripten limitations also apply to WASI. Noticable restrictions
@@ -376,6 +396,16 @@ git clone https://github.com/emscripten-core/emsdk.git /opt/emsdk
376
396
/opt/emsdk/emsdk activate latest
377
397
```
378
398
399
+ ### Optionally: enable ccache for EMSDK
400
+
401
+ The `` EM_COMPILER_WRAPPER `` must be set after the EMSDK environment is
402
+ sourced. Otherwise the source script removes the environment variable.
403
+
404
+ ```
405
+ . /opt/emsdk/emsdk_env.sh
406
+ EM_COMPILER_WRAPPER=ccache
407
+ ```
408
+
379
409
### Optionally: pre-build and cache static libraries
380
410
381
411
Emscripten SDK provides static builds of core libraries without PIC
@@ -384,12 +414,8 @@ PIC. To populate the build cache, run:
384
414
385
415
``` shell
386
416
. /opt/emsdk/emsdk_env.sh
387
- embuilder build --force zlib bzip2
388
- embuilder build --force --pic \
389
- zlib bzip2 libc-mt libdlmalloc-mt libsockets-mt \
390
- libstubs libcompiler_rt libcompiler_rt-mt crtbegin libhtml5 \
391
- libc++-mt-noexcept libc++abi-mt-noexcept \
392
- libal libGL-mt libstubs-debug libc-mt-debug
417
+ embuilder build zlib bzip2 MINIMAL_PIC
418
+ embuilder build --pic zlib bzip2 MINIMAL_PIC
393
419
```
394
420
395
421
### Install [ WASI-SDK] ( https://github.com/WebAssembly/wasi-sdk )
@@ -424,3 +450,9 @@ ln -srf -t /usr/local/bin/ ~/.wasmtime/bin/wasmtime
424
450
git clone https://github.com/singlestore-labs/wasix.git ~ /wasix
425
451
make install -C ~ /wasix
426
452
```
453
+
454
+ ### WASI debugging
455
+
456
+ * `` wasmtime run -g `` generates debugging symbols for gdb and lldb.
457
+ * The environment variable `` RUST_LOG=wasi_common `` enables debug and
458
+ trace logging.
0 commit comments