Skip to content

Commit fe42628

Browse files
tklausergopherbot
authored andcommitted
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 <[email protected]> Auto-Submit: Tobias Klauser <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Florian Lehner <[email protected]>
1 parent 94b7d51 commit fe42628

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

src/internal/cpu/cpu.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ package cpu
88

99
import _ "unsafe" // for linkname
1010

11-
// DebugOptions is set to true by the runtime if the OS supports reading
12-
// GODEBUG early in runtime startup.
13-
// This should not be changed after it is initialized.
14-
var DebugOptions bool
15-
1611
// CacheLinePad is used to pad structs to avoid false sharing.
1712
type CacheLinePad struct{ _ [CacheLinePadSize]byte }
1813

src/internal/cpu/cpu_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ import (
99
"internal/godebug"
1010
"internal/testenv"
1111
"os/exec"
12+
"runtime"
1213
"testing"
1314
)
1415

1516
func MustHaveDebugOptionsSupport(t *testing.T) {
16-
if !DebugOptions {
17+
switch runtime.GOOS {
18+
case "aix", "darwin", "ios", "dragonfly", "freebsd", "netbsd", "openbsd", "illumos", "solaris", "linux":
19+
default:
1720
t.Skipf("skipping test: cpu feature options not supported by OS")
1821
}
1922
}

src/runtime/proc.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,6 @@ const (
760760
// cpuinit sets up CPU feature flags and calls internal/cpu.Initialize. env should be the complete
761761
// value of the GODEBUG environment variable.
762762
func cpuinit(env string) {
763-
switch GOOS {
764-
case "aix", "darwin", "ios", "dragonfly", "freebsd", "netbsd", "openbsd", "illumos", "solaris", "linux":
765-
cpu.DebugOptions = true
766-
}
767763
cpu.Initialize(env)
768764

769765
// Support cpu feature variables are used in code generated by the compiler

0 commit comments

Comments
 (0)