Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get tests passing under wasmtime 18 using preview2 / WASI 0.2 primitives #116313

Closed
3 tasks done
brettcannon opened this issue Mar 4, 2024 · 3 comments
Closed
3 tasks done
Assignees
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes OS-wasi

Comments

@brettcannon
Copy link
Member

brettcannon commented Mar 4, 2024

This is a tracking issue for getting wasmtime --wasi preview2 working for wasmtime 18+ (older versions had bugs we needed fixed).

  • main
  • 3.12
  • 3.11

Linked PRs

@brettcannon brettcannon changed the title Get tests passing under wasmtime using preview2 / WASI 0.2 primitives Get tests passing under wasmtime 18 using preview2 / WASI 0.2 primitives Mar 4, 2024
@brettcannon
Copy link
Member Author

brettcannon commented Mar 4, 2024

A test run on main just passed! I still want to check 3.12 and 3.11.

diff --git a/Tools/wasm/wasi.py b/Tools/wasm/wasi.py
index 1e75db5c7b..d5317228fe 100644
--- a/Tools/wasm/wasi.py
+++ b/Tools/wasm/wasi.py
@@ -284,7 +284,8 @@ def main():
                         # which equates to 8291 KiB.
                         "--wasm max-wasm-stack=8388608 "
                         # Enable thread support.
-                        "--wasm threads=y --wasi threads=y "
+                        #"--wasm threads=y --wasi threads=y "
+                        "--wasi preview2 "
                         # Map the checkout to / to load the stdlib from /Lib.
                         "--dir {HOST_DIR}::{GUEST_DIR} "
                         # Set PYTHONPATH to the sysconfig data.

@brettcannon brettcannon added 3.11 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes labels Mar 4, 2024
@brettcannon
Copy link
Member Author

It also works under 3.12! As such, I don't assume any issues under 3.11.

diff --git a/Tools/wasm/wasm_build.py b/Tools/wasm/wasm_build.py
index c9947057a9..f6e2629656 100755
--- a/Tools/wasm/wasm_build.py
+++ b/Tools/wasm/wasm_build.py
@@ -316,8 +316,10 @@ def _check_wasi():
         # workaround for https://github.com/python/cpython/issues/95952
         "HOSTRUNNER": (
             "wasmtime run "
-            "--env PYTHONPATH=/{relbuilddir}/build/lib.wasi-wasm32-{version}:/Lib "
-            "--mapdir /::{srcdir} --"
+            "--wasm max-wasm-stack=8388608 "
+            "--wasi preview2 "
+            "--dir {srcdir}::/ "
+            "--env PYTHONPATH=/{relbuilddir}/build/lib.wasi-wasm32-{version}:/Lib"
         ),
         "PATH": [WASI_SDK_PATH / "bin", os.environ["PATH"]],
     },
diff --git a/configure.ac b/configure.ac
index 384718db1f..b3eaaa9246 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1601,7 +1601,7 @@ then
     dnl TODO: support other WASI runtimes
     dnl wasmtime starts the proces with "/" as CWD. For OOT builds add the
     dnl directory containing _sysconfigdata to PYTHONPATH.
-    [WASI/*], [HOSTRUNNER='wasmtime run --env PYTHONPATH=/$(shell realpath --relative-to $(abs_srcdir) $(abs_builddir))/$(shell cat pybuilddir.txt):/Lib --mapdir /::$(srcdir) --'],
+    [WASI/*], [HOSTRUNNER='wasmtime run --wasm max-wasm-stack=8388608 --wasi preview2 --env PYTHONPATH=/$(shell realpath --relative-to $(abs_srcdir) $(abs_builddir))/$(shell cat pybuilddir.txt):/Lib --dir $(srcdir)::/'],
     [HOSTRUNNER='']
   )
 fi

@brettcannon
Copy link
Member Author

I think I need python/buildmaster-config#469 merged before the PRs will pass on all the WASI buildbots.

kushaldas pushed a commit that referenced this issue Mar 5, 2024
…ew2 primitives (#116327)

* GH-116313: get WASI builds to run under wasmtime 18 w/ WASI 0.2/preview2 primitives

* Add the configure changes

* Update `wasm_build.py`
brettcannon added a commit to brettcannon/cpython that referenced this issue Mar 5, 2024
brettcannon added a commit that referenced this issue Mar 5, 2024
adorilson pushed a commit to adorilson/cpython that referenced this issue Mar 25, 2024
…/preview2 primitives (python#116327)

* pythonGH-116313: get WASI builds to run under wasmtime 18 w/ WASI 0.2/preview2 primitives

* Add the configure changes

* Update `wasm_build.py`
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…/preview2 primitives (python#116327)

* pythonGH-116313: get WASI builds to run under wasmtime 18 w/ WASI 0.2/preview2 primitives

* Add the configure changes

* Update `wasm_build.py`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes OS-wasi
Projects
None yet
Development

No branches or pull requests

1 participant