From 451c57af92795d2b9ddd479dedc09f0038b8aceb Mon Sep 17 00:00:00 2001 From: deadprogram Date: Fri, 10 Apr 2026 14:31:22 +0200 Subject: [PATCH] runtime: add syscall.runtimeClearenv for Go 1.26 Go 1.26 added syscall.runtimeClearenv (called by syscall.Clearenv) which must be provided by the runtime via go:linkname. Without it, the os package fails to link. --- src/runtime/env.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/runtime/env.go b/src/runtime/env.go index 72232e2f5..676c634d9 100644 --- a/src/runtime/env.go +++ b/src/runtime/env.go @@ -27,6 +27,16 @@ func syscallUnsetenv(key string) { unsetenv(&keydata[0]) } +// Clear the environment. +// Called from Go 1.26 and above. +// +//go:linkname syscallClearenv syscall.runtimeClearenv +func syscallClearenv(env map[string]int) { + for k := range env { + syscallUnsetenv(k) + } +} + // Compatibility with Go 1.19 and below. // //go:linkname syscall_setenv_c syscall.setenv_c