Source file src/internal/cpu/cpu_x86_darwin.go
1 // Copyright 2025 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build (386 || amd64) && darwin && !ios 6 7 package cpu 8 9 func osInit() { 10 if isRosetta() && darwinKernelVersionCheck(24, 0, 0) { 11 // Apparently, on macOS 15 (Darwin kernel version 24) or newer, 12 // Rosetta 2 supports AVX1 and 2. However, neither CPUID nor 13 // sysctl says it has AVX. Detect this situation here and report 14 // AVX1 and 2 as supported. 15 // TODO: check if any other feature is actually supported. 16 X86.HasAVX = true 17 X86.HasAVX2 = true 18 } 19 } 20 21 func isRosetta() bool { 22 return sysctlEnabled([]byte("sysctl.proc_translated\x00")) 23 } 24