diff --git a/generator/native/native.go b/generator/native/native.go index 7f3a7ed..9b71467 100644 --- a/generator/native/native.go +++ b/generator/native/native.go @@ -2,6 +2,7 @@ // 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) @@ -11,7 +12,50 @@ import "git.tebibyte.media/fspl/fspl/generator" // NativeTarget returns a target describing the current system. func NativeTarget () generator.Target { - target := nativeArch() - target.OS = nativeOS() + 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 } diff --git a/generator/native/native_386.go b/generator/native/native_386.go deleted file mode 100644 index b43ea15..0000000 --- a/generator/native/native_386.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 32, - Arch: "i386", - } -} diff --git a/generator/native/native_amd64.go b/generator/native/native_amd64.go deleted file mode 100644 index a25359c..0000000 --- a/generator/native/native_amd64.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 64, - Arch: "x86_64", - } -} diff --git a/generator/native/native_amd64p32.go b/generator/native/native_amd64p32.go deleted file mode 100644 index 82fff57..0000000 --- a/generator/native/native_amd64p32.go +++ /dev/null @@ -1,11 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - // this may not be accurate, can't find info online about amd64p32 - return generator.Target { - WordSize: 32, - Arch: "x86", - } -} diff --git a/generator/native/native_arm.go b/generator/native/native_arm.go deleted file mode 100644 index 6734b84..0000000 --- a/generator/native/native_arm.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 32, - Arch: "arm", - } -} diff --git a/generator/native/native_arm64.go b/generator/native/native_arm64.go deleted file mode 100644 index fb3bbc6..0000000 --- a/generator/native/native_arm64.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 64, - Arch: "aarch64", - } -} diff --git a/generator/native/native_arm64be.go b/generator/native/native_arm64be.go deleted file mode 100644 index a01ff49..0000000 --- a/generator/native/native_arm64be.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 64, - Arch: "aarch64_be", - } -} diff --git a/generator/native/native_armbe.go b/generator/native/native_armbe.go deleted file mode 100644 index b65ecd8..0000000 --- a/generator/native/native_armbe.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 32, - Arch: "armeb", - } -} diff --git a/generator/native/native_mips.go b/generator/native/native_mips.go deleted file mode 100644 index 4f04d48..0000000 --- a/generator/native/native_mips.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 32, - Arch: "mips", - } -} diff --git a/generator/native/native_mips64.go b/generator/native/native_mips64.go deleted file mode 100644 index 51b8728..0000000 --- a/generator/native/native_mips64.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 64, - Arch: "mips64", - } -} diff --git a/generator/native/native_mips64le.go b/generator/native/native_mips64le.go deleted file mode 100644 index 8388606..0000000 --- a/generator/native/native_mips64le.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 64, - Arch: "mips64el", - } -} diff --git a/generator/native/native_mipsle.go b/generator/native/native_mipsle.go deleted file mode 100644 index 8e0eb6a..0000000 --- a/generator/native/native_mipsle.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 32, - Arch: "mipsel", - } -} diff --git a/generator/native/native_ppc.go b/generator/native/native_ppc.go deleted file mode 100644 index 2b7406f..0000000 --- a/generator/native/native_ppc.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 32, - Arch: "ppc32", - } -} diff --git a/generator/native/native_ppc64.go b/generator/native/native_ppc64.go deleted file mode 100644 index 05b52fe..0000000 --- a/generator/native/native_ppc64.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 64, - Arch: "ppc64", - } -} diff --git a/generator/native/native_ppc64le.go b/generator/native/native_ppc64le.go deleted file mode 100644 index 7ebcf6f..0000000 --- a/generator/native/native_ppc64le.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 64, - Arch: "ppc64le", - } -} diff --git a/generator/native/native_riscv.go b/generator/native/native_riscv.go deleted file mode 100644 index f2b97e3..0000000 --- a/generator/native/native_riscv.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 32, - Arch: "riscv32", - } -} diff --git a/generator/native/native_sparc.go b/generator/native/native_sparc.go deleted file mode 100644 index 3fde94f..0000000 --- a/generator/native/native_sparc.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 32, - Arch: "sparc", - } -} diff --git a/generator/native/native_sparc64.go b/generator/native/native_sparc64.go deleted file mode 100644 index 65be0f6..0000000 --- a/generator/native/native_sparc64.go +++ /dev/null @@ -1,10 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - return generator.Target { - WordSize: 64, - Arch: "sparcv9", - } -} diff --git a/generator/native/native_wasm.go b/generator/native/native_wasm.go deleted file mode 100644 index a82c00e..0000000 --- a/generator/native/native_wasm.go +++ /dev/null @@ -1,12 +0,0 @@ -package native - -import "git.tebibyte.media/fspl/fspl/generator" - -func nativeArch () generator.Target { - // FIXME: golang doesn't discern between 32/64 bit wasm so we assume 64 - // bit here - return generator.Target { - WordSize: 64, - Arch: "wasm64", - } -} diff --git a/generator/native/osnative_aix.go b/generator/native/osnative_aix.go deleted file mode 100644 index 6cf1bf8..0000000 --- a/generator/native/osnative_aix.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "aix" -} diff --git a/generator/native/osnative_android.go b/generator/native/osnative_android.go deleted file mode 100644 index 9952e97..0000000 --- a/generator/native/osnative_android.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "linux" -} diff --git a/generator/native/osnative_darwin.go b/generator/native/osnative_darwin.go deleted file mode 100644 index 8abde5c..0000000 --- a/generator/native/osnative_darwin.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "darwin" -} diff --git a/generator/native/osnative_dragonfly.go b/generator/native/osnative_dragonfly.go deleted file mode 100644 index ee066e3..0000000 --- a/generator/native/osnative_dragonfly.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "dragonfly" -} diff --git a/generator/native/osnative_freebsd.go b/generator/native/osnative_freebsd.go deleted file mode 100644 index fa277c1..0000000 --- a/generator/native/osnative_freebsd.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "freebsd" -} diff --git a/generator/native/osnative_illumos.go b/generator/native/osnative_illumos.go deleted file mode 100644 index f1a80ed..0000000 --- a/generator/native/osnative_illumos.go +++ /dev/null @@ -1,6 +0,0 @@ -package native - -func nativeOS () string { - // does not seem to be supported by LLVM at the moment - return "illumos" -} diff --git a/generator/native/osnative_ios.go b/generator/native/osnative_ios.go deleted file mode 100644 index e77fd31..0000000 --- a/generator/native/osnative_ios.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "ios" -} diff --git a/generator/native/osnative_js.go b/generator/native/osnative_js.go deleted file mode 100644 index 8300389..0000000 --- a/generator/native/osnative_js.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "unknown" -} diff --git a/generator/native/osnative_linux.go b/generator/native/osnative_linux.go deleted file mode 100644 index 9952e97..0000000 --- a/generator/native/osnative_linux.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "linux" -} diff --git a/generator/native/osnative_nacl.go b/generator/native/osnative_nacl.go deleted file mode 100644 index a81151c..0000000 --- a/generator/native/osnative_nacl.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "nacl" -} diff --git a/generator/native/osnative_netbsd.go b/generator/native/osnative_netbsd.go deleted file mode 100644 index 498e1eb..0000000 --- a/generator/native/osnative_netbsd.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "netbsd" -} diff --git a/generator/native/osnative_openbsd.go b/generator/native/osnative_openbsd.go deleted file mode 100644 index 7311e48..0000000 --- a/generator/native/osnative_openbsd.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "openbsd" -} diff --git a/generator/native/osnative_plan9.go b/generator/native/osnative_plan9.go deleted file mode 100644 index 7f7f1f0..0000000 --- a/generator/native/osnative_plan9.go +++ /dev/null @@ -1,6 +0,0 @@ -package native - -func nativeOS () string { - // does not seem to be supported by LLVM at the moment - return "plan9" -} diff --git a/generator/native/osnative_solaris.go b/generator/native/osnative_solaris.go deleted file mode 100644 index 588c0c6..0000000 --- a/generator/native/osnative_solaris.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "solaris" -} diff --git a/generator/native/osnative_windows.go b/generator/native/osnative_windows.go deleted file mode 100644 index 3f14020..0000000 --- a/generator/native/osnative_windows.go +++ /dev/null @@ -1,5 +0,0 @@ -package native - -func nativeOS () string { - return "win32" -}