]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-116313: get WASI builds to run under wasmtime 18 w/ WASI 0.2/preview2 primitives...
authorBrett Cannon <brett@python.org>
Tue, 5 Mar 2024 08:18:53 +0000 (00:18 -0800)
committerGitHub <noreply@github.com>
Tue, 5 Mar 2024 08:18:53 +0000 (09:18 +0100)
* GH-116313: get WASI builds to run under wasmtime 18 w/ WASI 0.2/preview2 primitives

* Add the configure changes

* Update `wasm_build.py`

.devcontainer/Dockerfile
Misc/NEWS.d/next/Build/2024-03-04-12-43-42.gh-issue-116313.cLLb8S.rst [new file with mode: 0644]
Tools/wasm/wasi.py
Tools/wasm/wasm_build.py
configure
configure.ac

index 9f808af38e69df76663ad132c9c82e7bd6457ca0..365756458bba30ac7d05f5d795ebfe343f31febd 100644 (file)
@@ -6,7 +6,7 @@ ENV WASI_SDK_VERSION=20
 ENV WASI_SDK_PATH=/opt/wasi-sdk
 
 ENV WASMTIME_HOME=/opt/wasmtime
-ENV WASMTIME_VERSION=14.0.4
+ENV WASMTIME_VERSION=18.0.2
 ENV WASMTIME_CPU_ARCH=x86_64
 
 RUN dnf -y --nodocs --setopt=install_weak_deps=False install /usr/bin/{blurb,clang,curl,git,ln,tar,xz} 'dnf-command(builddep)' && \
diff --git a/Misc/NEWS.d/next/Build/2024-03-04-12-43-42.gh-issue-116313.cLLb8S.rst b/Misc/NEWS.d/next/Build/2024-03-04-12-43-42.gh-issue-116313.cLLb8S.rst
new file mode 100644 (file)
index 0000000..6150154
--- /dev/null
@@ -0,0 +1 @@
+Get WASI builds to work under wasmtime 18 w/ WASI 0.2/preview2 primitives.
index 1e75db5c7b83299d190a577463a577ec85f32ae4..efb005e53ab989b488f68a40573ec413a235327a 100644 (file)
@@ -283,8 +283,10 @@ def main():
                         # The 8388608 value comes from `ulimit -s` under Linux
                         # which equates to 8291 KiB.
                         "--wasm max-wasm-stack=8388608 "
-                        # Enable thread support.
-                        "--wasm threads=y --wasi threads=y "
+                        # Use WASI 0.2 primitives.
+                        "--wasi preview2 "
+                        # Enable thread support; causes use of preview1.
+                        #"--wasm threads=y --wasi threads=y "
                         # Map the checkout to / to load the stdlib from /Lib.
                         "--dir {HOST_DIR}::{GUEST_DIR} "
                         # Set PYTHONPATH to the sysconfig data.
index c0b9999a5dad037165c3a3ae9323bebeb818d179..47a0abb8b5feef23e8420d7bbe1d80fb73da1fe4 100755 (executable)
@@ -329,8 +329,10 @@ WASI = Platform(
         # 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"]],
     },
index 4a980fea4536979fce52629ef3969d72abe8ebb0..c758749cd371ed7950d11bd0b0d947804223520d 100755 (executable)
--- a/configure
+++ b/configure
@@ -7655,7 +7655,7 @@ then :
 fi
      ;; #(
               WASI/*) :
-    HOSTRUNNER='wasmtime run --env PYTHONPATH=/$(shell realpath --relative-to $(abs_srcdir) $(abs_builddir))/$(shell cat pybuilddir.txt):/Lib --mapdir /::$(srcdir) --' ;; #(
+    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=''
    ;;
index 103c24962b7b420efa54173a89934ed7ff200153..80d0a7edc7cad4aaf2b0d8db922570f04ca03ac8 100644 (file)
@@ -1537,7 +1537,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