Commit 888bac14 authored by Elias Naur's avatar Elias Naur

cmd/dist: detect GOHOSTARCH on iOS

cmd/dist defaults to GOHOSTARCH=amd64 on darwin because no other
darwin host could build Go. With the upcoming self-hosted iOS
builders, GOHOSTARCH=arm64 is also possible.

Updates #31722

Change-Id: I9af47d9f8c57ea45475ce498acefbfe6bf4815b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/174306
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent d7edc916
...@@ -60,9 +60,6 @@ func main() { ...@@ -60,9 +60,6 @@ func main() {
// uname -m doesn't work under AIX // uname -m doesn't work under AIX
gohostarch = "ppc64" gohostarch = "ppc64"
case "darwin": case "darwin":
// Even on 64-bit platform, darwin uname -m prints i386.
// We don't support any of the OS X versions that run on 32-bit-only hardware anymore.
gohostarch = "amd64"
// macOS 10.9 and later require clang // macOS 10.9 and later require clang
defaultclang = true defaultclang = true
case "freebsd": case "freebsd":
...@@ -107,6 +104,11 @@ func main() { ...@@ -107,6 +104,11 @@ func main() {
gohostarch = "amd64" gohostarch = "amd64"
case strings.Contains(out, "86"): case strings.Contains(out, "86"):
gohostarch = "386" gohostarch = "386"
if gohostos == "darwin" {
// Even on 64-bit platform, some versions of macOS uname -m prints i386.
// We don't support any of the OS X versions that run on 32-bit-only hardware anymore.
gohostarch = "amd64"
}
case strings.Contains(out, "aarch64"), strings.Contains(out, "arm64"): case strings.Contains(out, "aarch64"), strings.Contains(out, "arm64"):
gohostarch = "arm64" gohostarch = "arm64"
case strings.Contains(out, "arm"): case strings.Contains(out, "arm"):
...@@ -128,8 +130,8 @@ func main() { ...@@ -128,8 +130,8 @@ func main() {
case strings.Contains(out, "s390x"): case strings.Contains(out, "s390x"):
gohostarch = "s390x" gohostarch = "s390x"
case gohostos == "darwin": case gohostos == "darwin":
if strings.Contains(run("", CheckExit, "uname", "-v"), "RELEASE_ARM_") { if strings.Contains(run("", CheckExit, "uname", "-v"), "RELEASE_ARM64_") {
gohostarch = "arm" gohostarch = "arm64"
} }
default: default:
fatalf("unknown architecture: %s", out) fatalf("unknown architecture: %s", out)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment