From 8fc2696d4604b5be6d6689fc86af945151b64f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E9=B2=B2?= Date: Wed, 6 Mar 2024 21:21:25 +0800 Subject: [PATCH] fixbug: Apple Silicon build fail. --- internal/cpuid/cpuid_arm64.go | 20 +++++++++++++++++--- internal/cpuid/cpuid_arm64_darwin.go | 10 ---------- 2 files changed, 17 insertions(+), 13 deletions(-) delete mode 100644 internal/cpuid/cpuid_arm64_darwin.go diff --git a/internal/cpuid/cpuid_arm64.go b/internal/cpuid/cpuid_arm64.go index bb7fd87..05862e1 100644 --- a/internal/cpuid/cpuid_arm64.go +++ b/internal/cpuid/cpuid_arm64.go @@ -1,6 +1,20 @@ package cpuid -import "golang.org/x/sys/cpu" +import ( + "runtime" -var HasAES = cpu.ARM64.HasAES -var HasGFMUL = cpu.ARM64.HasPMULL + "golang.org/x/sys/cpu" +) + +var HasAES = false +var HasGFMUL = false + +func init() { + if runtime.GOOS == "darwin/arm64" { + HasAES = true + HasGFMUL = true + } else { + HasAES = cpu.ARM64.HasAES + HasGFMUL = cpu.ARM64.HasPMULL + } +} diff --git a/internal/cpuid/cpuid_arm64_darwin.go b/internal/cpuid/cpuid_arm64_darwin.go deleted file mode 100644 index 4ffbb53..0000000 --- a/internal/cpuid/cpuid_arm64_darwin.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build arm64 && darwin && !ios - -package cpuid - -// There are no hw.optional sysctl values for the below features on Mac OS 11.0 -// to detect their supported state dynamically. Assume the CPU features that -// Apple Silicon M1 supports to be available as a minimal set of features -// to all Go programs running on darwin/arm64. -var HasAES = true -var HasGFMUL = true