]> Cypherpunks repositories - gostls13.git/commitdiff
internal/cpu: remove option to mark cpu features required
authorMartin Möhrmann <martin@golang.org>
Wed, 6 Oct 2021 03:27:52 +0000 (05:27 +0200)
committerMartin Möhrmann <martin@golang.org>
Wed, 6 Oct 2021 18:44:56 +0000 (18:44 +0000)
With the removal of SSE2 runtime detection made in
golang.org/cl/344350 we can remove this mechanism as there
are no required features anymore.

For making sure CPUs running a go program support all
the minimal hardware requirements the go runtime should
do feature checks early in the runtime initialization
before it is likely any compiler emitted but unsupported
instructions are used. This is already the case for e.g.
checking MMX support on 386 arch targets.

Change-Id: If7b1cb6f43233841e917d37a18314d06a334a734
Reviewed-on: https://go-review.googlesource.com/c/go/+/354209
Trust: Martin Möhrmann <martin@golang.org>
Run-TryBot: Martin Möhrmann <martin@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/internal/cpu/cpu.go
src/internal/cpu/cpu_test.go

index 4f0c5d2896bfa9d13489ddfc3308bc976c6ea132..30745344e1c816e5986f386c0c112ebb981f98b2 100644 (file)
@@ -136,7 +136,6 @@ type option struct {
        Feature   *bool
        Specified bool // whether feature value was specified in GODEBUG
        Enable    bool // whether feature should be enabled
-       Required  bool // whether feature is mandatory and can not be disabled
 }
 
 // processOptions enables or disables CPU feature values based on the parsed env string.
@@ -179,7 +178,7 @@ field:
                if key == "all" {
                        for i := range options {
                                options[i].Specified = true
-                               options[i].Enable = enable || options[i].Required
+                               options[i].Enable = enable
                        }
                        continue field
                }
@@ -205,11 +204,6 @@ field:
                        continue
                }
 
-               if !o.Enable && o.Required {
-                       print("GODEBUG: can not disable \"", o.Name, "\", required CPU feature\n")
-                       continue
-               }
-
                *o.Feature = o.Enable
        }
 }
index 2de7365732d7482242648068aa78bdd77453ab25..06ad20800f9c6a3dd5efe539bc5a87cfeb619c02 100644 (file)
@@ -9,28 +9,10 @@ import (
        "internal/testenv"
        "os"
        "os/exec"
-       "runtime"
        "strings"
        "testing"
 )
 
-func TestMinimalFeatures(t *testing.T) {
-       // TODO: maybe do MustSupportFeatureDectection(t) ?
-       if runtime.GOARCH == "arm64" {
-               switch runtime.GOOS {
-               case "linux", "android", "darwin":
-               default:
-                       t.Skipf("%s/%s is not supported", runtime.GOOS, runtime.GOARCH)
-               }
-       }
-
-       for _, o := range Options {
-               if o.Required && !*o.Feature {
-                       t.Errorf("%v expected true, got false", o.Name)
-               }
-       }
-}
-
 func MustHaveDebugOptionsSupport(t *testing.T) {
        if !DebugOptions {
                t.Skipf("skipping test: cpu feature options not supported by OS")
@@ -75,7 +57,7 @@ func TestAllCapabilitiesDisabled(t *testing.T) {
        }
 
        for _, o := range Options {
-               want := o.Required
+               want := false
                if got := *o.Feature; got != want {
                        t.Errorf("%v: expected %v, got %v", o.Name, want, got)
                }