golang/go

x/sys/cpu: cpu.ARM64.SHA512 not correctly set for Mac M1

Closed this issue · 2 comments

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:

ARM64.HasSHA512 = sysctlEnabled([]byte("hw.optional.armv8_2_sha512\x00"))

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.

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