Skip to content

Commit 519a814

Browse files
committed
runtime: handle GODEBUG on wasip2
1 parent f6c759c commit 519a814

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

src/runtime/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build linux || darwin || windows || wasip1
1+
//go:build (linux || darwin || windows || wasip1) && !wasip2
22

33
package runtime
44

src/runtime/env_wasip2.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//go:build wasip2
2+
3+
package runtime
4+
5+
// Notify the runtime when environment variables change.
6+
// On wasip2, the environment is managed in Go (no C setenv), but
7+
// internal/godebug still needs to be notified of GODEBUG changes.
8+
9+
//go:linkname syscallSetenv syscall.runtimeSetenv
10+
func syscallSetenv(key, value string) {
11+
if key == "GODEBUG" && godebugUpdate != nil {
12+
godebugUpdate(key, value)
13+
}
14+
}
15+
16+
//go:linkname syscallUnsetenv syscall.runtimeUnsetenv
17+
func syscallUnsetenv(key string) {
18+
}

src/syscall/env_wasip2.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ func Setenv(key, val string) (err error) {
4343
}
4444
}
4545
libc_envs[key] = val
46+
runtimeSetenv(key, val)
4647
return nil
4748
}
4849

4950
func Unsetenv(key string) (err error) {
5051
delete(libc_envs, key)
52+
runtimeUnsetenv(key)
5153
return nil
5254
}
5355

0 commit comments

Comments
 (0)