type option struct {
Name string
Feature *bool
- Specified bool // Stores if feature value was specified in GODEBUGCPU.
- Enable bool // Stores if feature should be enabled.
+ Specified bool // whether feature value was specified in GODEBUGCPU
+ 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.
if key == "all" {
for i := range options {
options[i].Specified = true
- options[i].Enable = enable
+ options[i].Enable = enable || options[i].Required
}
continue field
}
continue
}
+ if !o.Enable && o.Required {
+ print("GODEBUGCPU: can not disable \"", o.Name, "\", required feature\n")
+ continue
+ }
+
*o.Feature = o.Enable
}
}
{Name: "asimdfhm", Feature: &ARM64.HasASIMDFHM},
// These capabilities should always be enabled on arm64:
- // {Name: "fp", Feature: &ARM64.HasFP},
- // {Name: "asimd", Feature: &ARM64.HasASIMD},
+ {Name: "fp", Feature: &ARM64.HasFP, Required: true},
+ {Name: "asimd", Feature: &ARM64.HasASIMD, Required: true},
}
// HWCAP feature bits
{Name: "scv", Feature: &PPC64.HasSCV},
// These capabilities should always be enabled on ppc64 and ppc64le:
- // {Name: "vmx", Feature: &PPC64.HasVMX},
- // {Name: "dfp", Feature: &PPC64.HasDFP},
- // {Name: "vsx", Feature: &PPC64.HasVSX},
- // {Name: "isel", Feature: &PPC64.HasISEL},
- // {Name: "vcrypto", Feature: &PPC64.HasVCRYPTO},
+ {Name: "vmx", Feature: &PPC64.HasVMX, Required: true},
+ {Name: "dfp", Feature: &PPC64.HasDFP, Required: true},
+ {Name: "vsx", Feature: &PPC64.HasVSX, Required: true},
+ {Name: "isel", Feature: &PPC64.HasISEL, Required: true},
+ {Name: "vcrypto", Feature: &PPC64.HasVCRYPTO, Required: true},
}
// HWCAP feature bits
}
for _, o := range Options {
- if got := *o.Feature; got != false {
- t.Errorf("%v: expected false, got %v", o.Name, got)
+ want := o.Required
+ if got := *o.Feature; got != want {
+ t.Errorf("%v: expected %v, got %v", o.Name, want, got)
}
}
}
{Name: "sse42", Feature: &X86.HasSSE42},
{Name: "ssse3", Feature: &X86.HasSSSE3},
- // sse2 set as last element so it can easily be removed again. See code below.
- {Name: "sse2", Feature: &X86.HasSSE2},
- }
-
- // Remove sse2 from options on amd64(p32) because SSE2 is a mandatory feature for these GOARCHs.
- if GOARCH == "amd64" || GOARCH == "amd64p32" {
- options = options[:len(options)-1]
+ // These capabilities should always be enabled on amd64(p32):
+ {Name: "sse2", Feature: &X86.HasSSE2, Required: GOARCH == "amd64" || GOARCH == "amd64p32"},
}
maxID, _, _, _ := cpuid(0, 0)