updated vendor

This commit is contained in:
2026-06-16 08:02:19 +02:00
parent 2f7f99d3f0
commit 77299d0c64
1283 changed files with 67302 additions and 208958 deletions
+2 -17
View File
@@ -1,28 +1,13 @@
package platform
import (
"runtime"
"golang.org/x/sys/cpu"
)
import "golang.org/x/sys/cpu"
// CpuFeatures exposes the capabilities for this CPU, queried via the Has method.
var CpuFeatures = loadCpuFeatureFlags()
func loadCpuFeatureFlags() (flags CpuFeatureFlags) {
switch runtime.GOOS {
case "darwin", "windows":
// These OSes do not allow userland to read the instruction set attribute registers,
// but basically require atomic instructions:
// - "darwin" is the desktop version (mobile version is "ios"),
// and the M1 is a ARMv8.4.
// - "windows" requires them from Windows 11, see page 12
// https://download.microsoft.com/download/7/8/8/788bf5ab-0751-4928-a22c-dffdc23c27f2/Minimum%20Hardware%20Requirements%20for%20Windows%2011.pdf
if cpu.ARM64.HasATOMICS {
flags |= CpuFeatureArm64Atomic
default:
if cpu.ARM64.HasATOMICS {
flags |= CpuFeatureArm64Atomic
}
}
return
}
+23 -1
View File
@@ -14,6 +14,14 @@ func CompilerSupported() bool {
}
func CompilerSupports(features api.CoreFeatures) bool {
if !compilerPlatformSupports(features) {
return false
}
// Won't panic
return executableMmapSupported()
}
func compilerPlatformSupports(features api.CoreFeatures) bool {
switch runtime.GOOS {
case "linux", "darwin", "freebsd", "netbsd", "windows":
if runtime.GOARCH == "arm64" {
@@ -30,7 +38,7 @@ func CompilerSupports(features api.CoreFeatures) bool {
}
}
// MmapCodeSegment copies the code into the executable region and returns the byte slice of the region.
// MmapCodeSegment allocates and returns a byte slice to copy executable code into.
//
// See https://man7.org/linux/man-pages/man2/mmap.2.html for mmap API and flags.
func MmapCodeSegment(size int) ([]byte, error) {
@@ -47,3 +55,17 @@ func MunmapCodeSegment(code []byte) error {
}
return munmapCodeSegment(code)
}
func executableMmapSupported() bool {
seg, err := MmapCodeSegment(1)
if err != nil {
return false
}
defer func() {
_ = MunmapCodeSegment(seg)
}()
if err := MprotectCodeSegment(seg); err != nil {
return false
}
return true
}