Skip to content

Commit 68775d9

Browse files
[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.
1 parent c890a55 commit 68775d9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

CoreFoundation/Base.subproj/CFPlatform.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include <mach-o/dyld.h>
2323
#endif
2424

25+
#if TARGET_OS_WASI
26+
#include <wasi/libc-environ.h>
27+
#endif
28+
2529
#define _CFEmitInternalDiagnostics 0
2630

2731

@@ -1812,8 +1816,10 @@ CF_EXPORT char **_CFEnviron(void) {
18121816
return *_NSGetEnviron();
18131817
#elif TARGET_OS_WIN32
18141818
return _environ;
1819+
#elif TARGET_OS_WASI
1820+
return __wasilibc_get_environ();
18151821
#else
1816-
#if TARGET_OS_BSD || TARGET_OS_WASI
1822+
#if TARGET_OS_BSD
18171823
extern char **environ;
18181824
#endif
18191825
return environ;

0 commit comments

Comments
 (0)