Skip to content

Commit 1fc8bd3

Browse files
authoredSep 11, 2022
gh-95853: Multiple ops and debug for wasm_build.py (#96744)
1 parent 8d75a13 commit 1fc8bd3

File tree

5 files changed

+248
-83
lines changed

5 files changed

+248
-83
lines changed
 

‎Lib/distutils/tests/test_sysconfig.py

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def test_get_config_vars(self):
4848
self.assertIsInstance(cvars, dict)
4949
self.assertTrue(cvars)
5050

51+
@unittest.skipIf(is_wasi, "Incompatible with WASI mapdir and OOT builds")
5152
def test_srcdir(self):
5253
# See Issues #15322, #15364.
5354
srcdir = sysconfig.get_config_var('srcdir')

‎Lib/test/test_sysconfig.py

+1
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ def test_platform_in_subprocess(self):
438438
self.assertEqual(status, 0)
439439
self.assertEqual(my_platform, test_platform)
440440

441+
@unittest.skipIf(is_wasi, "Incompatible with WASI mapdir and OOT builds")
441442
def test_srcdir(self):
442443
# See Issues #15322, #15364.
443444
srcdir = sysconfig.get_config_var('srcdir')

‎Makefile.pre.in

+4
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,10 @@ buildbottest: all
17181718
fi
17191719
$(TESTRUNNER) -j 1 -u all -W --slowest --fail-env-changed --timeout=$(TESTTIMEOUT) $(TESTOPTS)
17201720

1721+
# Like testall, but run Python tests with HOSTRUNNER directly.
1722+
hostrunnertest: all
1723+
$(RUNSHARED) $(HOSTRUNNER) ./$(BUILDPYTHON) -m test -u all $(TESTOPTS)
1724+
17211725
pythoninfo: all
17221726
$(RUNSHARED) $(HOSTRUNNER) ./$(BUILDPYTHON) -m test.pythoninfo
17231727

‎Tools/wasm/README.md

+40-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# Python WebAssembly (WASM) build
22

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.**
44

55
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.
914

1015
## wasm32-emscripten build
1116

@@ -17,7 +22,7 @@ access the file system directly.
1722

1823
Cross compiling to the wasm32-emscripten platform needs the
1924
[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
2126
to a repository checkout.
2227

2328
Christian Heimes maintains a container image with Emscripten SDK, Python
@@ -336,26 +341,46 @@ if os.name == "posix":
336341
```python
337342
>>> import os, sys
338343
>>> 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+
)
340351
>>> os.name
341352
'posix'
342353
>>> sys.platform
343354
'emscripten'
344355
>>> sys._emscripten_info
345356
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',
348359
pthreads=False,
349360
shared_memory=False
350361
)
362+
```
363+
364+
```python
351365
>>> 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+
)
353372
```
354373

355374
```python
356375
>>> import os, sys
357376
>>> 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+
)
359384
>>> os.name
360385
'posix'
361386
>>> sys.platform
@@ -446,7 +471,8 @@ embuilder build --pic zlib bzip2 MINIMAL_PIC
446471

447472
**NOTE**: WASI-SDK's clang may show a warning on Fedora:
448473
``/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.
450476

451477
```shell
452478
export WASI_VERSION=16
@@ -471,6 +497,8 @@ ln -srf -t /usr/local/bin/ ~/.wasmtime/bin/wasmtime
471497

472498
### WASI debugging
473499

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 .
475503
* The environment variable ``RUST_LOG=wasi_common`` enables debug and
476504
trace logging.

0 commit comments

Comments
 (0)
Please sign in to comment.