From dff45c266e6c6103ab324c4771a21d5b52ef85ba Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 27 Feb 2024 22:52:30 -0700 Subject: [PATCH] wasi.c: report no environment variables available I moved part of the compiler that checks environment variables to the standard library, so it doesn't have access to `build_options.only_c` anymore, which means some environment variable checks are leaking into the zig1.wasm build of zig. This logic still makes it return "no environment variables found" though. --- stage1/wasi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stage1/wasi.c b/stage1/wasi.c index bbbaac488b..b4533e0a3f 100644 --- a/stage1/wasi.c +++ b/stage1/wasi.c @@ -662,13 +662,15 @@ uint32_t wasi_snapshot_preview1_fd_filestat_set_times(uint32_t fd, uint64_t atim } uint32_t wasi_snapshot_preview1_environ_sizes_get(uint32_t environ_size, uint32_t environ_buf_size) { - (void)environ_size; - (void)environ_buf_size; + uint8_t *const m = *wasm_memory; + uint32_t *environ_size_ptr = (uint32_t *)&m[environ_size]; + uint32_t *environ_buf_size_ptr = (uint32_t *)&m[environ_buf_size]; #if LOG_TRACE fprintf(stderr, "wasi_snapshot_preview1_environ_sizes_get()\n"); #endif - panic("unimplemented"); + *environ_size_ptr = 0; + *environ_buf_size_ptr = 0; return wasi_errno_success; }