From 0887c854acb39fb995476dff607574974d9cceca Mon Sep 17 00:00:00 2001 From: Mitch Date: Thu, 26 Feb 2026 10:21:49 -0500 Subject: [PATCH] fix: write pointers for environ_get and environ_sizes_get functions --- .../cpp/src/barretenberg/wasi/wasi_stubs.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/wasi/wasi_stubs.cpp b/barretenberg/cpp/src/barretenberg/wasi/wasi_stubs.cpp index af2520e76c42..31258e97195e 100644 --- a/barretenberg/cpp/src/barretenberg/wasi/wasi_stubs.cpp +++ b/barretenberg/cpp/src/barretenberg/wasi/wasi_stubs.cpp @@ -59,17 +59,22 @@ int32_t __imported_wasi_snapshot_preview1_fd_close(int32_t) return 0; } -int32_t __imported_wasi_snapshot_preview1_environ_get(int32_t, int32_t) +int32_t __imported_wasi_snapshot_preview1_environ_get(int32_t environ_ptr, int32_t environ_buf_ptr) { - // info("environ_get not implemented."); - // abort(); + // No environment variables, so nothing to write. The pointers point to + // arrays that would hold the environ entries and the concatenated + // key=value strings respectively, but with count == 0 they are empty. + (void)environ_ptr; + (void)environ_buf_ptr; return 0; } -int32_t __imported_wasi_snapshot_preview1_environ_sizes_get(int32_t, int32_t) +int32_t __imported_wasi_snapshot_preview1_environ_sizes_get(int32_t count_ptr, int32_t buf_size_ptr) { - // info("environ_sizes_get not implemented."); - // abort(); + // WASI requires writing the number of environment variables and the total + // buffer size needed to hold them. We have none of either. + *(int32_t*)(uintptr_t)count_ptr = 0; + *(int32_t*)(uintptr_t)buf_size_ptr = 0; return 0; }