targets: match LLVM triple to the one Clang uses

The target triples have to match mostly to be able to link LLVM modules.
Linking LLVM modules is already possible (the triples already match),
but testing becomes much easier when they match exactly.

For macOS, I picked "macosx10.12.0". That's an old and unsupported
version, but I had to pick _something_. Clang by default uses
"macos10.4.0", which is much older.
This commit is contained in:
Ayke van Laethem
2021-11-04 00:22:42 +01:00
committed by Ron Evans
parent fb33f3813d
commit fce403b7a0
15 changed files with 29 additions and 16 deletions
+11 -1
View File
@@ -165,7 +165,6 @@ func LoadTarget(options *Options) (*TargetSpec, error) {
if options.Target == "" {
// Configure based on GOOS/GOARCH environment variables (falling back to
// runtime.GOOS/runtime.GOARCH), and generate a LLVM target based on it.
llvmos := options.GOOS
llvmarch := map[string]string{
"386": "i386",
"amd64": "x86_64",
@@ -175,6 +174,17 @@ func LoadTarget(options *Options) (*TargetSpec, error) {
if llvmarch == "" {
llvmarch = options.GOARCH
}
llvmos := options.GOOS
if llvmos == "darwin" {
// Use macosx* instead of darwin, otherwise darwin/arm64 will refer
// to iOS!
llvmos = "macosx10.12.0"
if llvmarch == "aarch64" {
// Looks like Apple prefers to call this architecture ARM64
// instead of AArch64.
llvmarch = "arm64"
}
}
// Target triples (which actually have four components, but are called
// triples for historical reasons) have the form:
// arch-vendor-os-environment