mirror of
https://github.com/golang/go.git
synced 2025-05-15 12:24:37 +00:00
internal/cpu: enable support for GODEBUGCPU in non-experimental builds
Enabling GODEBUGCPU without the need to set GOEXPERIMENT=debugcpu enables trybots and builders to run tests for GODEBUGCPU features in upcoming CLs that will implement the new syntax and features for non-experimental GODEBUGCPU support from proposal golang.org/issue/27218. Updates #27218 Change-Id: Icc69e51e736711a86b02b46bd441ffc28423beba Reviewed-on: https://go-review.googlesource.com/c/141817 Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
da6c168378
commit
a5248acd91
@ -105,7 +105,6 @@ var (
|
|||||||
Fieldtrack_enabled int
|
Fieldtrack_enabled int
|
||||||
Preemptibleloops_enabled int
|
Preemptibleloops_enabled int
|
||||||
Clobberdead_enabled int
|
Clobberdead_enabled int
|
||||||
DebugCPU_enabled int
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Toolchain experiments.
|
// Toolchain experiments.
|
||||||
@ -120,7 +119,6 @@ var exper = []struct {
|
|||||||
{"framepointer", &framepointer_enabled},
|
{"framepointer", &framepointer_enabled},
|
||||||
{"preemptibleloops", &Preemptibleloops_enabled},
|
{"preemptibleloops", &Preemptibleloops_enabled},
|
||||||
{"clobberdead", &Clobberdead_enabled},
|
{"clobberdead", &Clobberdead_enabled},
|
||||||
{"debugcpu", &DebugCPU_enabled},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultExpstring = Expstring()
|
var defaultExpstring = Expstring()
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
// used by the Go standard library.
|
// used by the Go standard library.
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
// DebugOptions is set to true by the runtime if go was compiled with GOEXPERIMENT=debugcpu
|
// DebugOptions is set to true by the runtime if the OS supports GODEBUGCPU.
|
||||||
// and GOOS is Linux or Darwin.
|
|
||||||
// This should not be changed after it is initialized.
|
// This should not be changed after it is initialized.
|
||||||
var DebugOptions bool
|
var DebugOptions bool
|
||||||
|
|
||||||
@ -139,8 +138,7 @@ type s390x struct {
|
|||||||
|
|
||||||
// Initialize examines the processor and sets the relevant variables above.
|
// Initialize examines the processor and sets the relevant variables above.
|
||||||
// This is called by the runtime package early in program initialization,
|
// This is called by the runtime package early in program initialization,
|
||||||
// before normal init functions are run. env is set by runtime on Linux and Darwin
|
// before normal init functions are run. env is set by runtime if the OS supports GODEBUGCPU.
|
||||||
// if go was compiled with GOEXPERIMENT=debugcpu.
|
|
||||||
func Initialize(env string) {
|
func Initialize(env string) {
|
||||||
doinit()
|
doinit()
|
||||||
processOptions(env)
|
processOptions(env)
|
||||||
|
@ -13,14 +13,14 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MustHaveDebugOptionsEnabled(t *testing.T) {
|
func MustHaveDebugOptionsSupport(t *testing.T) {
|
||||||
if !DebugOptions {
|
if !DebugOptions {
|
||||||
t.Skipf("skipping test: cpu feature options not enabled")
|
t.Skipf("skipping test: cpu feature options not supported by OS")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func runDebugOptionsTest(t *testing.T, test string, options string) {
|
func runDebugOptionsTest(t *testing.T, test string, options string) {
|
||||||
MustHaveDebugOptionsEnabled(t)
|
MustHaveDebugOptionsSupport(t)
|
||||||
|
|
||||||
testenv.MustHaveExec(t)
|
testenv.MustHaveExec(t)
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ func TestDisableAllCapabilities(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAllCapabilitiesDisabled(t *testing.T) {
|
func TestAllCapabilitiesDisabled(t *testing.T) {
|
||||||
MustHaveDebugOptionsEnabled(t)
|
MustHaveDebugOptionsSupport(t)
|
||||||
|
|
||||||
if os.Getenv("GODEBUGCPU") != "all=0" {
|
if os.Getenv("GODEBUGCPU") != "all=0" {
|
||||||
t.Skipf("skipping test: GODEBUGCPU=all=0 not set")
|
t.Skipf("skipping test: GODEBUGCPU=all=0 not set")
|
||||||
|
@ -34,7 +34,7 @@ func TestDisableSSE2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSSE2DebugOption(t *testing.T) {
|
func TestSSE2DebugOption(t *testing.T) {
|
||||||
MustHaveDebugOptionsEnabled(t)
|
MustHaveDebugOptionsSupport(t)
|
||||||
|
|
||||||
if os.Getenv("GODEBUGCPU") != "sse2=0" {
|
if os.Getenv("GODEBUGCPU") != "sse2=0" {
|
||||||
t.Skipf("skipping test: GODEBUGCPU=sse2=0 not set")
|
t.Skipf("skipping test: GODEBUGCPU=sse2=0 not set")
|
||||||
|
@ -478,12 +478,12 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// cpuinit extracts the environment variable GODEBUGCPU from the environment on
|
// cpuinit extracts the environment variable GODEBUGCPU from the environment on
|
||||||
// Linux and Darwin if the GOEXPERIMENT debugcpu was set and calls internal/cpu.Initialize.
|
// Linux and Darwin and calls internal/cpu.Initialize.
|
||||||
func cpuinit() {
|
func cpuinit() {
|
||||||
const prefix = "GODEBUGCPU="
|
const prefix = "GODEBUGCPU="
|
||||||
var env string
|
var env string
|
||||||
|
|
||||||
if haveexperiment("debugcpu") && (GOOS == "linux" || GOOS == "darwin") {
|
if GOOS == "linux" || GOOS == "darwin" {
|
||||||
cpu.DebugOptions = true
|
cpu.DebugOptions = true
|
||||||
|
|
||||||
// Similar to goenv_unix but extracts the environment value for
|
// Similar to goenv_unix but extracts the environment value for
|
||||||
|
Loading…
x
Reference in New Issue
Block a user