cross compilation
This commit is contained in:
55
internal/xtool/llvm/llvm.go
Normal file
55
internal/xtool/llvm/llvm.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package llvm
|
||||
|
||||
import "runtime"
|
||||
|
||||
func GetTargetTriple(goos, goarch string) string {
|
||||
var llvmarch string
|
||||
if goarch == "" {
|
||||
goarch = runtime.GOARCH
|
||||
}
|
||||
if goos == "" {
|
||||
goos = runtime.GOOS
|
||||
}
|
||||
switch goarch {
|
||||
case "386":
|
||||
llvmarch = "i386"
|
||||
case "amd64":
|
||||
llvmarch = "x86_64"
|
||||
case "arm64":
|
||||
llvmarch = "aarch64"
|
||||
case "arm":
|
||||
switch goarch {
|
||||
case "5":
|
||||
llvmarch = "armv5"
|
||||
case "6":
|
||||
llvmarch = "armv6"
|
||||
default:
|
||||
llvmarch = "armv7"
|
||||
}
|
||||
case "wasm":
|
||||
llvmarch = "wasm32"
|
||||
default:
|
||||
llvmarch = goarch
|
||||
}
|
||||
llvmvendor := "unknown"
|
||||
llvmos := goos
|
||||
switch goos {
|
||||
case "darwin":
|
||||
// Use macosx* instead of darwin, otherwise darwin/arm64 will refer
|
||||
// to iOS!
|
||||
llvmos = "macosx"
|
||||
if llvmarch == "aarch64" {
|
||||
// Looks like Apple prefers to call this architecture ARM64
|
||||
// instead of AArch64.
|
||||
llvmarch = "arm64"
|
||||
llvmos = "macosx"
|
||||
}
|
||||
llvmvendor = "apple"
|
||||
case "wasip1":
|
||||
llvmos = "wasip1"
|
||||
}
|
||||
// Target triples (which actually have four components, but are called
|
||||
// triples for historical reasons) have the form:
|
||||
// arch-vendor-os-environment
|
||||
return llvmarch + "-" + llvmvendor + "-" + llvmos
|
||||
}
|
||||
Reference in New Issue
Block a user