x/sys/cpu: ARM64.HasAES = false on Apple Silicon (M1 Max)
aadomnicai opened this issue · 9 comments
What version of Go are you using (go version)?
$ go version go version go1.22.2 darwin/arm64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE='' GOARCH='arm64' GOBIN='' GOCACHE='/Users/alexandre.adomnicai/Library/Caches/go-build' GOENV='/Users/alexandre.adomnicai/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users/alexandre.adomnicai/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='darwin' GOPATH='/Users/alexandre.adomnicai/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/opt/homebrew/Cellar/go/1.22.2/libexec' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.2/libexec/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.22.2' GCCGO='gccgo' AR='ar' CC='cc' CXX='c++' CGO_ENABLED='1' GOMOD='/Users/alexandre.adomnicai/Github/test_aes/go.mod' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/31/w4yrhpr51z15j6f6wml61kvr0000gp/T/go-build1310596040=/tmp/go-build -gno-record-gcc-switches -fno-common' GOROOT/bin/go version: go version go1.22.2 darwin/arm64 GOROOT/bin/go tool compile -V: compile version go1.22.2 uname -v: Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 ProductName: macOS ProductVersion: 14.5 BuildVersion: 23F79 lldb --version: lldb-1500.0.404.7 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
What did you do?
Run a simple test to check whether hardware AES is used on my machine.
The following is simply run with go test -tags ""
package aes_test
import (
"fmt"
"testing"
"golang.org/x/sys/cpu"
)
func TestEncryptDecryptMessage(t *testing.T) {
fmt.Printf("Hardware AES is used: %t\n", cpu.ARM64.HasAES)
}
What did you expect to see?
I would have expected Hardware AES is used: true since AES instructions are supported.
In go/src/internal/cpu/cpu_arm64_darwin.go, the variable cpu.ARM64.HasAES should be set to true, and I cannot understand why that is not the case since the build conditions //go:build arm64 && darwin && !ios should be satisfied?
What did you see instead?
I get Hardware AES is used: false instead.
Similar Issues
- go build #52634
- darwin/arm64 binary says it is running under Rosetta 2 on macOS M1 machine #44733
- Demo #66258
- yaffaliu #56935
- sb #53220
- Bugs-Report #62338
- x/sys/cpu: cpu.X86.HasAVX512 is incorrectly always false on darwin #43089
- clear #57553
- ARM64(M1 Mac) - bad CPU type in executable cgo #64750
- Test #67906
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
It looks like x/sys/cpu parses registers https://go.googlesource.com/sys/+/76700875dfcc135287c18189252576117307b695/cpu/cpu_arm64.go#73
While the go repo's internal/cpu just assumes support https://go.googlesource.com/go/+/e8ee1dc4f9e2632ba1018610d1a1187743ae397f/src/internal/cpu/cpu_arm64_darwin.go#20
Thanks for pointing this out.
Any insight on why this has not been merged so far?
Thanks for pointing this out.
Any insight on why this has not been merged so far?
I need to make the fixes requested by the reviewers, then it needs to be reviewed again.
This is mostly a dupe of #43046