Skip to content

Commit 6694d23

Browse files
committed
GH-115978: Disable *readv() and *writev() on WASI
Wasmtime doesn't implement them in a way to pass test_posix (bytecodealliance/wasmtime#7830). This fix allows running under WASI 0.2 primitives for wasmtime.
1 parent 90a1e98 commit 6694d23

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ENV WASI_SDK_VERSION=20
66
ENV WASI_SDK_PATH=/opt/wasi-sdk
77

88
ENV WASMTIME_HOME=/opt/wasmtime
9-
ENV WASMTIME_VERSION=14.0.4
9+
ENV WASMTIME_VERSION=18.0.2
1010
ENV WASMTIME_CPU_ARCH=x86_64
1111

1212
RUN dnf -y --nodocs --setopt=install_weak_deps=False install /usr/bin/{blurb,clang,curl,git,ln,tar,xz} 'dnf-command(builddep)' && \
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Disable preadv(), readv(), pwritev(), and writev() on WASI.
2+
3+
Under wasmtime for WASI 0.2, these functions don't pass test_posix
4+
(https://github.com/bytecodealliance/wasmtime/issues/7830).

Tools/wasm/config.site-wasm32-wasi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,12 @@ ac_cv_header_netpacket_packet_h=no
4040

4141
# Disable int-conversion for wask-sdk as it triggers an error from version 17.
4242
ac_cv_disable_int_conversion=yes
43+
44+
# preadv(), readv(), pwritev(), and writev() under wasmtime's WASI 0.2 support
45+
# do not use more than the first buffer provided, failing under test_posix.
46+
# Since wasmtime will not be changing this behaviour, disable the functions.
47+
# https://github.com/bytecodealliance/wasmtime/issues/7830
48+
ac_cv_func_preadv=no
49+
ac_cv_func_readv=no
50+
ac_cv_func_pwritev=no
51+
ac_cv_func_writev=no

Tools/wasm/wasi.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,23 @@ def clean_contents(context):
277277

278278

279279
def main():
280-
default_host_runner = (f"{shutil.which('wasmtime')} run "
281-
# Make sure the stack size will work for a pydebug
282-
# build.
283-
# The 8388608 value comes from `ulimit -s` under Linux
284-
# which equates to 8291 KiB.
285-
"--wasm max-wasm-stack=8388608 "
286-
# Enable thread support.
287-
"--wasm threads=y --wasi threads=y "
288-
# Map the checkout to / to load the stdlib from /Lib.
289-
"--dir {HOST_DIR}::{GUEST_DIR} "
290-
# Set PYTHONPATH to the sysconfig data.
291-
"--env {ENV_VAR_NAME}={ENV_VAR_VALUE}")
280+
host_runner_parts = [
281+
f"{shutil.which('wasmtime')} run",
282+
# Make sure the stack size will work for a pydebug
283+
# build.
284+
# The 8388608 value comes from `ulimit -s` under Linux
285+
# which equates to 8291 KiB.
286+
"--wasm max-wasm-stack=8388608",
287+
# Enable thread support.
288+
#"--wasm threads=y --wasi threads=y "
289+
# Use WASI 0.2 primitives
290+
"--wasi preview2",
291+
# Map the checkout to / to load the stdlib from /Lib.
292+
"--dir {HOST_DIR}::{GUEST_DIR}",
293+
# Set PYTHONPATH to the sysconfig data.
294+
"--env {ENV_VAR_NAME}={ENV_VAR_VALUE}"
295+
]
296+
default_host_runner = " ".join(host_runner_parts)
292297

293298
parser = argparse.ArgumentParser()
294299
subcommands = parser.add_subparsers(dest="subcommand")

0 commit comments

Comments
 (0)