1
1
# Python WebAssembly (WASM) build
2
2
3
- ** WARNING: WASM support is highly experimental ! Lots of features are not working yet.**
3
+ ** WARNING: WASM support is work-in-progress ! Lots of features are not working yet.**
4
4
5
5
This directory contains configuration and helpers to facilitate cross
6
- compilation of CPython to WebAssembly (WASM). For now we support
7
- * wasm32-emscripten* builds for modern browser and for * Node.js* . WASI
8
- (* wasm32-wasi* ) is work-in-progress
6
+ compilation of CPython to WebAssembly (WASM). Python supports Emscripten
7
+ (* wasm32-emscripten* ) and WASI (* wasm32-wasi* ) targets. Emscripten builds
8
+ run in modern browsers and JavaScript runtimes like * Node.js* . WASI builds
9
+ use WASM runtimes such as * wasmtime* .
10
+
11
+ Users and developers are encouraged to use the script
12
+ ` Tools/wasm/wasm_build.py ` . The tool automates the build process and provides
13
+ assistance with installation of SDKs.
9
14
10
15
## wasm32-emscripten build
11
16
@@ -17,7 +22,7 @@ access the file system directly.
17
22
18
23
Cross compiling to the wasm32-emscripten platform needs the
19
24
[ Emscripten] ( https://emscripten.org/ ) SDK and a build Python interpreter.
20
- Emscripten 3.1.8 or newer are recommended. All commands below are relative
25
+ Emscripten 3.1.19 or newer are recommended. All commands below are relative
21
26
to a repository checkout.
22
27
23
28
Christian Heimes maintains a container image with Emscripten SDK, Python
@@ -336,26 +341,46 @@ if os.name == "posix":
336
341
``` python
337
342
>> > import os, sys
338
343
>> > os.uname()
339
- posix.uname_result(sysname = ' Emscripten' , nodename = ' emscripten' , release = ' 1.0' , version = ' #1' , machine = ' wasm32' )
344
+ posix.uname_result(
345
+ sysname = ' Emscripten' ,
346
+ nodename = ' emscripten' ,
347
+ release = ' 3.1.19' ,
348
+ version = ' #1' ,
349
+ machine = ' wasm32'
350
+ )
340
351
>> > os.name
341
352
' posix'
342
353
>> > sys.platform
343
354
' emscripten'
344
355
>> > sys._emscripten_info
345
356
sys._emscripten_info(
346
- emscripten_version = (3 , 1 , 8 ),
347
- runtime = ' Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:99 .0) Gecko/20100101 Firefox/99 .0' ,
357
+ emscripten_version = (3 , 1 , 10 ),
358
+ runtime = ' Mozilla/5.0 (X11; Linux x86_64; rv:104 .0) Gecko/20100101 Firefox/104 .0' ,
348
359
pthreads = False ,
349
360
shared_memory = False
350
361
)
362
+ ```
363
+
364
+ ``` python
351
365
>> > sys._emscripten_info
352
- sys._emscripten_info(emscripten_version = (3 , 1 , 8 ), runtime = ' Node.js v14.18.2' , pthreads = True , shared_memory = True )
366
+ sys._emscripten_info(
367
+ emscripten_version = (3 , 1 , 19 ),
368
+ runtime = ' Node.js v14.18.2' ,
369
+ pthreads = True ,
370
+ shared_memory = True
371
+ )
353
372
```
354
373
355
374
``` python
356
375
>> > import os, sys
357
376
>> > os.uname()
358
- posix.uname_result(sysname = ' wasi' , nodename = ' (none)' , release = ' 0.0.0' , version = ' 0.0.0' , machine = ' wasm32' )
377
+ posix.uname_result(
378
+ sysname = ' wasi' ,
379
+ nodename = ' (none)' ,
380
+ release = ' 0.0.0' ,
381
+ version = ' 0.0.0' ,
382
+ machine = ' wasm32'
383
+ )
359
384
>> > os.name
360
385
' posix'
361
386
>> > sys.platform
@@ -446,7 +471,8 @@ embuilder build --pic zlib bzip2 MINIMAL_PIC
446
471
447
472
** NOTE** : WASI-SDK's clang may show a warning on Fedora:
448
473
`` /lib64/libtinfo.so.6: no version information available `` ,
449
- [ RHBZ #1875587 ] ( https://bugzilla.redhat.com/show_bug.cgi?id=1875587 ) .
474
+ [ RHBZ #1875587 ] ( https://bugzilla.redhat.com/show_bug.cgi?id=1875587 ) . The
475
+ warning can be ignored.
450
476
451
477
``` shell
452
478
export WASI_VERSION=16
@@ -471,6 +497,8 @@ ln -srf -t /usr/local/bin/ ~/.wasmtime/bin/wasmtime
471
497
472
498
### WASI debugging
473
499
474
- * `` wasmtime run -g `` generates debugging symbols for gdb and lldb.
500
+ * `` wasmtime run -g `` generates debugging symbols for gdb and lldb. The
501
+ feature is currently broken, see
502
+ https://github.com/bytecodealliance/wasmtime/issues/4669 .
475
503
* The environment variable `` RUST_LOG=wasi_common `` enables debug and
476
504
trace logging.
0 commit comments