]> Cypherpunks repositories - gostls13.git/commitdiff
internal/cpu: inline DebugOptions
authorTobias Klauser <tklauser@distanz.ch>
Thu, 28 Aug 2025 14:50:12 +0000 (16:50 +0200)
committerGopher Robot <gobot@golang.org>
Fri, 29 Aug 2025 17:01:06 +0000 (10:01 -0700)
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 <khr@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
src/internal/cpu/cpu.go
src/internal/cpu/cpu_test.go
src/runtime/proc.go

index e92c1851a214675318722be750be57b578a1c97e..9470b532df46e8f0e9562aa015f497ec057333d2 100644 (file)
@@ -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 }
 
index 3bff9bed4ea4c2f995b85cefcc72864898ba56b8..62e250d1e820061359f9de1821182e74fffec1c2 100644 (file)
@@ -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")
        }
 }
index 5b1c4906af3d1da42788a12e4e32e875d293fcf0..2584eb4cac6a33d6e1eed433b55d9de3e54acf62 100644 (file)
@@ -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