diff --git a/internal/platform/platform.go b/internal/platform/platform.go index ebc19a9b..0156e35c 100644 --- a/internal/platform/platform.go +++ b/internal/platform/platform.go @@ -10,6 +10,9 @@ import ( "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. func CompilerSupported() bool { switch runtime.GOOS { @@ -18,13 +21,7 @@ func CompilerSupported() bool { return false } - switch runtime.GOARCH { - case "amd64", "arm64": - default: - return false - } - - return true + return archRequirementsVerified } // MmapCodeSegment copies the code into the executable region and returns the byte slice of the region. diff --git a/internal/platform/platform_amd64.go b/internal/platform/platform_amd64.go new file mode 100644 index 00000000..4437e98f --- /dev/null +++ b/internal/platform/platform_amd64.go @@ -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) +} diff --git a/internal/platform/platform_arm64.go b/internal/platform/platform_arm64.go new file mode 100644 index 00000000..caac58a3 --- /dev/null +++ b/internal/platform/platform_arm64.go @@ -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 +}