You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for WebAssembly System Interface (wasm32-wasi) #90473
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/tiran'closed_at=Nonecreated_at=<Date2022-01-09.14:47:43.508>labels= ['type-feature', 'build', '3.11']
title='Add support for WebAssembly System Interface (wasm32-wasi)'updated_at=<Date2022-04-02.21:11:46.918>user='https://github.com/tiran'
WASI is another WebAssembly platform similar to Emscripten (bpo-40280). Simply speaking Emscripten binaries (wasm32-emscripten) run inside a browser while WASI binaries target standalone runtimes like wasmtime [2][3] on the host. The lines are a bit blurry, as it is possible to run WASI binaries in the browser with help of JS-polyfills. WASI provides compile once, run anyway with JIT/AOT and sandboxing.
WASI is still under development and is lacking several core features:
threading support and pthread API
sockets
signals are emulated (_WASI_EMULATED_SIGNAL and -lwasi-emulated-signal)
DAC APIs like chmod, umask
user-related APIs like pwd, grp
dup(), dup2(), F_DUPFD
For 3.11 I plan to fix our use of #ifdef HAVE_FEATURE to make it easier to experiment with WASI. The pthread APIs need stubs, which I won't commit to 3.11 upstream yet.
keithw on #wasi pointed out that fopencookie() can archive the same outcome without resorting to ABI-specific hack. A trivial implementation is straight forward:
Activity
tiran commentedon Jan 9, 2022
WASI is another WebAssembly platform similar to Emscripten (bpo-40280). Simply speaking Emscripten binaries (wasm32-emscripten) run inside a browser while WASI binaries target standalone runtimes like wasmtime [2][3] on the host. The lines are a bit blurry, as it is possible to run WASI binaries in the browser with help of JS-polyfills. WASI provides compile once, run anyway with JIT/AOT and sandboxing.
WASI is still under development and is lacking several core features:
For 3.11 I plan to fix our use of #ifdef HAVE_FEATURE to make it easier to experiment with WASI. The pthread APIs need stubs, which I won't commit to 3.11 upstream yet.
[1] https://wasi.dev/
[2] https://github.com/bytecodealliance/wasmtime
[3] https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/
tiran commentedon Jan 10, 2022
dup() is required by _PyTokenizer_FindEncodingFilename(). I came up with this hack:
keithw on #wasi pointed out that fopencookie() can archive the same outcome without resorting to ABI-specific hack. A trivial implementation is straight forward:
static ssize_t
borrow_read(void *cookie, char *buf, size_t size)
{
borrowed b;
b.cookie = cookie;
return read(b.fd, (void *)buf, size);
}
tiran commentedon Jan 13, 2022
New changeset a6ca8ee by Christian Heimes in branch 'main':
bpo-46315: Add ifdef HAVE_ feature checks for WASI compatibility (GH-30507)
a6ca8ee
tiran commentedon Apr 2, 2022
New changeset 3df0e63 by Christian Heimes in branch 'main':
bpo-46315: Use fopencookie only on Emscripten 3.x and newer (GH-32266)
3df0e63
81 remaining items
pythongh-90473: Fix more tests on platforms without umask
pythongh-90473: Check for HAVE_KILL in main.c:exit_sigint
gh-90473: Fix more tests on platforms without umask (GH-95164)
pythongh-90473: Fix more tests on platforms without umask (pythonGH-9…
gh-90473: Check for HAVE_KILL in main.c:exit_sigint (GH-95165)
pythongh-90473: Check for HAVE_KILL in main.c:exit_sigint (pythonGH-9…
gh-90473: Fix more tests on platforms without umask (GH-95164)
gh-90473: Check for HAVE_KILL in main.c:exit_sigint (GH-95165)
brettcannon commentedon Mar 28, 2023
Since we can build for WASI without patches now, I'm closing this as finished!