From fe42628dae69c907bc579219a38fce6bc8f18c6c Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 28 Aug 2025 16:50:12 +0200 Subject: [PATCH] internal/cpu: inline DebugOptions internal/cpu.DebugOptions is only ever set in runtime.cpuinit on unix-like platforms. DebugOptions itself is only used in MustHaveDebugOptionsSupport, so inline the GOOS check there. Change-Id: I6a35d6b8afcdadfc59585258002f53c20026116c Reviewed-on: https://go-review.googlesource.com/c/go/+/699775 Reviewed-by: Keith Randall Auto-Submit: Tobias Klauser Reviewed-by: Keith Randall Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI Reviewed-by: Florian Lehner --- src/internal/cpu/cpu.go | 5 ----- src/internal/cpu/cpu_test.go | 5 ++++- src/runtime/proc.go | 4 ---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/internal/cpu/cpu.go b/src/internal/cpu/cpu.go index e92c1851a21..9470b532df4 100644 --- a/src/internal/cpu/cpu.go +++ b/src/internal/cpu/cpu.go @@ -8,11 +8,6 @@ package cpu import _ "unsafe" // for linkname -// DebugOptions is set to true by the runtime if the OS supports reading -// GODEBUG early in runtime startup. -// This should not be changed after it is initialized. -var DebugOptions bool - // CacheLinePad is used to pad structs to avoid false sharing. type CacheLinePad struct{ _ [CacheLinePadSize]byte } diff --git a/src/internal/cpu/cpu_test.go b/src/internal/cpu/cpu_test.go index 3bff9bed4ea..62e250d1e82 100644 --- a/src/internal/cpu/cpu_test.go +++ b/src/internal/cpu/cpu_test.go @@ -9,11 +9,14 @@ import ( "internal/godebug" "internal/testenv" "os/exec" + "runtime" "testing" ) func MustHaveDebugOptionsSupport(t *testing.T) { - if !DebugOptions { + switch runtime.GOOS { + case "aix", "darwin", "ios", "dragonfly", "freebsd", "netbsd", "openbsd", "illumos", "solaris", "linux": + default: t.Skipf("skipping test: cpu feature options not supported by OS") } } diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 5b1c4906af3..2584eb4cac6 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -760,10 +760,6 @@ const ( // cpuinit sets up CPU feature flags and calls internal/cpu.Initialize. env should be the complete // value of the GODEBUG environment variable. func cpuinit(env string) { - switch GOOS { - case "aix", "darwin", "ios", "dragonfly", "freebsd", "netbsd", "openbsd", "illumos", "solaris", "linux": - cpu.DebugOptions = true - } cpu.Initialize(env) // Support cpu feature variables are used in code generated by the compiler