62 lines
2.7 KiB
Go
62 lines
2.7 KiB
Go
// Package native provides a generator target describing the current system.
|
|
// This is accomplished using several conditionally compiled source files.
|
|
package native
|
|
|
|
import "runtime"
|
|
import "git.tebibyte.media/fspl/fspl/generator"
|
|
|
|
// LLVM supported operating systems (note: capitalization is wrong)
|
|
// https://llvm.org/doxygen/Triple_8h_source.html
|
|
// GOOS and GOARCH values:
|
|
// https://go.dev/doc/install/source#environment
|
|
|
|
// NativeTarget returns a target describing the current system.
|
|
func NativeTarget () generator.Target {
|
|
target := generator.Target { }
|
|
switch runtime.GOARCH {
|
|
case "386": target.WordSize = 32; target.Arch = "i386"
|
|
case "amd64": target.WordSize = 64; target.Arch = "x86_64"
|
|
case "amd64p32": target.WordSize = 32; target.Arch = "x86" // might be inaccurate
|
|
case "arm": target.WordSize = 32; target.Arch = "arm"
|
|
case "arm64": target.WordSize = 64; target.Arch = "aarch64"
|
|
case "arm64be": target.WordSize = 64; target.Arch = "aarch64_be"
|
|
case "armbe": target.WordSize = 32; target.Arch = "armeb"
|
|
case "loong": target.WordSize = 32; target.Arch = "loongarch32"
|
|
case "loong64": target.WordSize = 64; target.Arch = "loongarch64"
|
|
case "mips": target.WordSize = 32; target.Arch = "mips"
|
|
case "mips64": target.WordSize = 64; target.Arch = "mips64"
|
|
case "mips64le": target.WordSize = 64; target.Arch = "mips64el"
|
|
case "mipsle": target.WordSize = 32; target.Arch = "mipsel"
|
|
case "ppc": target.WordSize = 32; target.Arch = "ppc32"
|
|
case "ppc64": target.WordSize = 64; target.Arch = "ppc64"
|
|
case "ppc64le": target.WordSize = 64; target.Arch = "ppc64le"
|
|
case "riscv": target.WordSize = 32; target.Arch = "riscv32"
|
|
case "riscv64": target.WordSize = 64; target.Arch = "riscv64"
|
|
case "sparc": target.WordSize = 32; target.Arch = "sparc"
|
|
case "sparc64": target.WordSize = 64; target.Arch = "sparcv9"
|
|
case "wasm": target.WordSize = 64; target.Arch = "wasm64"
|
|
default: target.WordSize = 64; target.Arch = "unknown"
|
|
}
|
|
switch runtime.GOOS {
|
|
case "aix": target.OS = "aix"
|
|
case "android": target.OS = "linux"
|
|
case "darwin": target.OS = "darwin"
|
|
case "dragonfly": target.OS = "dragonfly"
|
|
case "freebsd": target.OS = "freebsd"
|
|
case "illumos": target.OS = "illumos"
|
|
case "ios": target.OS = "ios"
|
|
case "js": target.OS = "unknown"
|
|
case "linux": target.OS = "linux"
|
|
case "nacl": target.OS = "nacl"
|
|
case "netbsd": target.OS = "netbsd"
|
|
case "openbsd": target.OS = "openbsd"
|
|
case "plan9": target.OS = "plan9" // does not seem to be supported by LLVM at the moment
|
|
case "solaris": target.OS = "solaris"
|
|
case "wasip1": target.OS = "wasi"
|
|
case "windows": target.OS = "win32"
|
|
default: target.OS = "unknown"
|
|
}
|
|
|
|
return target
|
|
}
|