]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: avoid lapsing into x86 builds on ARM64 Macs
authorRuss Cox <rsc@golang.org>
Sun, 16 Jan 2022 17:58:45 +0000 (12:58 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 18 Jan 2022 14:56:19 +0000 (14:56 +0000)
We use uname -m to decide the GOHOSTARCH default,
and on my ARM64 Mac laptop, uname -m prints x86_64.

uname -a prints:

Darwin p1.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:01 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T6000 x86_64

(Note the x86_64 at the end, consistent with uname -m.)

The effect of this is that make.bash builds an x86 toolchain
even when I start with an ARM64 bootstrap toolchain!
Avoid being tricked by looking for RELEASE_ARM64 instead.

Fixes #50643.

Change-Id: I76eded84bde8009d29419d5982bf964a0bf1c8fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/378894
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/dist/main.go

index 37de1acc317b348e2c72cb5c1687030157b34329..212d5cbe45cf133f8221e0a583dc6298d0d4e1c0 100644 (file)
@@ -94,7 +94,15 @@ func main() {
        if gohostarch == "" {
                // Default Unix system.
                out := run("", CheckExit, "uname", "-m")
+               outAll := run("", CheckExit, "uname", "-a")
                switch {
+               case strings.Contains(outAll, "RELEASE_ARM64"):
+                       // MacOS prints
+                       // Darwin p1.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:01 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T6000 x86_64
+                       // on ARM64 laptops when there is an x86 parent in the
+                       // process tree. Look for the RELEASE_ARM64 to avoid being
+                       // confused into building an x86 toolchain.
+                       gohostarch = "arm64"
                case strings.Contains(out, "x86_64"), strings.Contains(out, "amd64"):
                        gohostarch = "amd64"
                case strings.Contains(out, "86"):