compiler(amd64): return false on SSE4 unsupported CPUs (#1121)

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Co-authored-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
This commit is contained in:
Edoardo Vacchi
2023-02-14 00:33:18 +01:00
committed by GitHub
parent b68ee641cc
commit 28b0084e62
3 changed files with 18 additions and 7 deletions

View File

@@ -10,6 +10,9 @@ import (
"runtime" "runtime"
) )
// archRequirementsVerified is set by platform-specific init to true if the platform is supported
var archRequirementsVerified bool
// CompilerSupported is exported for tests and includes constraints here and also the assembler. // CompilerSupported is exported for tests and includes constraints here and also the assembler.
func CompilerSupported() bool { func CompilerSupported() bool {
switch runtime.GOOS { switch runtime.GOOS {
@@ -18,13 +21,7 @@ func CompilerSupported() bool {
return false return false
} }
switch runtime.GOARCH { return archRequirementsVerified
case "amd64", "arm64":
default:
return false
}
return true
} }
// MmapCodeSegment copies the code into the executable region and returns the byte slice of the region. // MmapCodeSegment copies the code into the executable region and returns the byte slice of the region.

View File

@@ -0,0 +1,7 @@
package platform
// init verifies that the current CPU supports the required AMD64 instructions
func init() {
// Ensure SSE4.1 is supported.
archRequirementsVerified = CpuFeatures.Has(CpuFeatureSSE4_1)
}

View File

@@ -0,0 +1,7 @@
package platform
// init verifies that the current CPU supports the required ARM64 features
func init() {
// No further checks currently needed.
archRequirementsVerified = true
}