FreeBSD was disabled due to lack of testing. This works around the compilation problems. Note: We can't currently test arm64 automatically! Notes: * GitHub Actions doesn’t support FreeBSD, and may never. * We could use Travis to run FreeBSD, but it would split our CI config. * Using Vagrant directly is easier to debug than vmactions/freebsd-vm. * GitHub Actions only supports virtualization on MacOS. * GitHub Actions removed vagrant from the image starting with macos-11. * Since VirtualBox doesn't work on arm64, freebsd/arm64 is untestabl Signed-off-by: Adrian Cole <adrian@tetrate.io> Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io> Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
// Package platform includes runtime-specific code needed for the compiler or otherwise.
|
|
//
|
|
// Note: This is a dependency-free alternative to depending on parts of Go's x/sys.
|
|
// See /RATIONALE.md for more context.
|
|
package platform
|
|
|
|
import (
|
|
"errors"
|
|
"runtime"
|
|
)
|
|
|
|
// CompilerSupported is exported for tests and includes constraints here and also the assembler.
|
|
func CompilerSupported() bool {
|
|
switch runtime.GOOS {
|
|
case "darwin", "windows", "linux", "freebsd":
|
|
default:
|
|
return false
|
|
}
|
|
|
|
switch runtime.GOARCH {
|
|
case "amd64", "arm64":
|
|
default:
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// MmapCodeSegment copies the code into the executable region and returns the byte slice of the region.
|
|
//
|
|
// See https://man7.org/linux/man-pages/man2/mmap.2.html for mmap API and flags.
|
|
func MmapCodeSegment(code []byte) ([]byte, error) {
|
|
if len(code) == 0 {
|
|
panic(errors.New("BUG: MmapCodeSegment with zero length"))
|
|
}
|
|
if runtime.GOARCH == "amd64" {
|
|
return mmapCodeSegmentAMD64(code)
|
|
} else {
|
|
return mmapCodeSegmentARM64(code)
|
|
}
|
|
}
|
|
|
|
// MunmapCodeSegment unmaps the given memory region.
|
|
func MunmapCodeSegment(code []byte) error {
|
|
if len(code) == 0 {
|
|
panic(errors.New("BUG: MunmapCodeSegment with zero length"))
|
|
}
|
|
return munmapCodeSegment(code)
|
|
}
|