x/sys/cpu: cpu.ARM64.SHA512 not correctly set for Mac M1
Closed this issue · 2 comments
egonelbre commented
Go version
go1.25.3
Output of go env in your module/workspace:
AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/egon/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/egon/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/yr/rzc9gn3d1mddybrx9v7220x80000gn/T/go-build1299921938=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/egon/code/golang.org/x/sys/go.mod'
GOMODCACHE='/Users/egon/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/egon/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/egon/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25.3'
GOWORK=''
PKG_CONFIG='pkg-config'What did you do?
While using cpu.ARM64.SHA512 I noticed that it's not true on M1, however internal/cpu/ARM64.HasSHA512 is true.
It seems that internal/cpu has some extra logic that's not present in golang.org/x/sys/cpu:
go/src/internal/cpu/cpu_arm64_darwin.go
Line 18 in ad3ccd9
What did you see happen?
The flag values of internal/cpu and golang.org/x/sys/cpu differ.
What did you expect to see?
I would expect them to be the same.
gabyhelp commented
Related Issues
- x/sys/cpu: ARM64.HasAES = false on Apple Silicon (M1 Max) #68150 (closed)
- x/sys/cpu: cpu.X86.HasAVX512 is incorrectly always false on darwin #43089 (closed)
- cpu: add HasSHA3 on darwin/arm64 #46300 (closed)
- internal/cpu: should detect AVX512 #26505 (closed)
Related Code Changes
- internal/cpu: add sha512 for arm64
- cpu: add HasSHA3 on darwin/arm64
- internal/cpu: add ARM64.HasSHA3
- cpu: add HasSHA512 feature bit in ARM64
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
prattmic commented
Looks like this is a duplicate of #43046. x/sys/cpu has no darwin-arm64 support: https://cs.opensource.google/go/x/sys/+/master:cpu/cpu_arm64.go;l=46;bpv=1