From b03da69c1de51eb1eef286da607bd80ddd0f6456 Mon Sep 17 00:00:00 2001 From: Char Date: Wed, 29 Apr 2026 11:07:56 +0800 Subject: [PATCH] wasm: add more stubbed file operations Match the tinygo 0.41.0/0.41.1 commit: https://github.com/tinygo-org/tinygo/commit/020cca8c3c24b9e5e2515cd859cb4fa752027bae --- cmd/workers-assets-gen/assets/wasm_exec_tinygo.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/workers-assets-gen/assets/wasm_exec_tinygo.js b/cmd/workers-assets-gen/assets/wasm_exec_tinygo.js index 01ad1af..64aa299 100644 --- a/cmd/workers-assets-gen/assets/wasm_exec_tinygo.js +++ b/cmd/workers-assets-gen/assets/wasm_exec_tinygo.js @@ -245,9 +245,11 @@ } const timeOrigin = Date.now() - performance.now(); + const wasi_EBADF = 8; + const wasi_ENOSYS = 52; this.importObject = { wasi_snapshot_preview1: { - // https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#fd_write + // https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md fd_write: function(fd, iovs_ptr, iovs_len, nwritten_ptr) { let nwritten = 0; if (fd == 1) { @@ -276,9 +278,13 @@ mem().setUint32(nwritten_ptr, nwritten, true); return 0; }, - fd_close: () => 0, // dummy - fd_fdstat_get: () => 0, // dummy - fd_seek: () => 0, // dummy + fd_read: () => wasi_ENOSYS, + fd_close: () => wasi_ENOSYS, + fd_fdstat_get: () => wasi_ENOSYS, + fd_prestat_get: () => wasi_EBADF, // wasi-libc relies on this errno value + fd_prestat_dir_name: () => wasi_ENOSYS, + fd_seek: () => wasi_ENOSYS, + path_open: () => wasi_ENOSYS, proc_exit: (code) => { this.exited = true; this.exitCode = code;