From 68775d9fbcd63afbd98f407d8e387188f4b53c19 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 4 Feb 2024 16:31:06 +0000 Subject: [PATCH] [wasm] Use `__wasilibc_get_environ` to get environ The `environ` variable in wasi-libc need to be accessed through the `__wasilibc_get_environ` function to ensure that it is initialized properly. --- CoreFoundation/Base.subproj/CFPlatform.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CoreFoundation/Base.subproj/CFPlatform.c b/CoreFoundation/Base.subproj/CFPlatform.c index 040e8966f2..672a437526 100644 --- a/CoreFoundation/Base.subproj/CFPlatform.c +++ b/CoreFoundation/Base.subproj/CFPlatform.c @@ -22,6 +22,10 @@ #include #endif +#if TARGET_OS_WASI +#include +#endif + #define _CFEmitInternalDiagnostics 0 @@ -1812,8 +1816,10 @@ CF_EXPORT char **_CFEnviron(void) { return *_NSGetEnviron(); #elif TARGET_OS_WIN32 return _environ; +#elif TARGET_OS_WASI + return __wasilibc_get_environ(); #else -#if TARGET_OS_BSD || TARGET_OS_WASI +#if TARGET_OS_BSD extern char **environ; #endif return environ;