Repository: go
Issue: build: arm64 machine building with 32-bit arm GOROOT_BOOTSTRAP fails
Labels: NeedsInvestigation

This is super low priority, but filing it because I hit it while experimenting.

ARM64 machines can run ARM code.

On an ARM64 machine I can build Go with make.bash and get ARM64 binaries, of course.

And I can run make.bash with GOARCH=arm, GOHOSTARCH=arm, CC_FOR_TARGET=arm-linux-gnueabihf-gcc, and get ARM binaries.

But if I set GOROOT_BOOTSTRAP to a 32-bit ARM GOROOT (from golang.org/dl), I can't build GOARCH=arm64, regardless of GOHOSTARCH or CC_FOR_TARGET settings.

I get either:

```
# runtime/cgo
gcc: error: unrecognized command line option '-marm'; did you mean '-fasm'?
go tool dist: FAILED: /home/ubuntu/gotip/pkg/tool/linux_arm/go_bootstrap install -gcflags=all= -ldflags=all= std cmd: exit status 2
```

or e.g.

```
$ GOROOT_BOOTSTRAP=$HOME/arm/go GOARCH=arm64 GOHOSTARCH=arm64 time ./make.bash 
Building Go cmd/dist using /home/ubuntu/arm/go. (go1.13.4 linux/arm)
Building Go toolchain1 using /home/ubuntu/arm/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
HASH[build runtime/internal/sys]
HASH[build runtime/internal/sys]: "devel +198f0452b0 Thu Nov 7 02:33:31 2019 +0000"
HASH[build runtime/internal/sys]: "compile\n"
HASH[build runtime/internal/sys]: "goos linux goarch arm64\n"
HASH[build runtime/internal/sys]: "import \"runtime/internal/sys\"\n"
HASH[build runtime/internal/sys]: "omitdebug false standard true local false prefix \"\"\n"
HASH[build runtime/internal/sys]: "modinfo \"\"\n"
HASH[build runtime/internal/sys]: "compile NrSOTEoiK7YosNNhxRnR [] []\n"
HASH[build runtime/internal/sys]: "=\n"
HASH /home/ubuntu/gotip/src/runtime/internal/sys/arch.go: d9b0b7e72538d421b2607acaba60ca49f20ef584b3d1d191c6729e35fbb8101d
HASH[build runtime/internal/sys]: "file arch.go 2bC35yU41CGyYHrKumDK\n"
HASH /home/ubuntu/gotip/src/runtime/internal/sys/arch_arm64.go: 2fe66f385ea5a1e9da31d7674ec907c441ba78c4ea17aaec217330fcb0105474
HASH[build runtime/internal/sys]: "file arch_arm64.go L-ZvOF6loenaMddnTskH\n"
HASH /home/ubuntu/gotip/src/runtime/internal/sys/intrinsics.go: 8b469a461e1d983706e0b3635715ce70691adc5db7c4e067b88cc59f40cd66f4
HASH[build runtime/internal/sys]: "file intrinsics.go i0aaRh4dmDcG4LNjVxXO\n"
HASH /home/ubuntu/gotip/src/runtime/internal/sys/stubs.go: 23b3e5c631b086fe7a2dec4bf044600e034bf6a8eeb25e0a19efc4ce6311423d
HASH[build runtime/internal/sys]: "file stubs.go I7PlxjGwhv56LexL8ERg\n"
HASH /home/ubuntu/gotip/src/runtime/internal/sys/sys.go: 55e021891200a7e6a5c371c8a1ab71b6c15aeb16ea6c1b192185d17df8c8b18f
HASH[build runtime/internal/sys]: "file sys.go VeAhiRIAp-alw3HIoatx\n"
HASH /home/ubuntu/gotip/src/runtime/internal/sys/zgoarch_arm64.go: 4902d69a4a20421a799ba2e2c07d8b279aeb73993cbdcb9358c703809446e436
HASH[build runtime/internal/sys]: "file zgoarch_arm64.go SQLWmkogQhp5m6LiwH2L\n"
HASH /home/ubuntu/gotip/src/runtime/internal/sys/zgoos_linux.go: 806c088d7491b4560a28a5af86a52b459ebbf155ea455af873baa0bf697355e4
HASH[build runtime/internal/sys]: "file zgoos_linux.go gGwIjXSRtFYKKKWvhqUr\n"
HASH /home/ubuntu/gotip/src/runtime/internal/sys/zversion.go: bf440002e6d73c527f836969303ab545ace7032498d0fa287bd8ba5e335d06cf
HASH[build runtime/internal/sys]: "file zversion.go v0QAAubXPFJ_g2lpMDq1\n"
HASH[build runtime/internal/sys]: 112806be5693d6fbb50a08689c94b2089080eac354c33437afda01d394b49e79
runtime/internal/sys true
go tool dist: unexpected stale targets reported by /home/ubuntu/gotip/pkg/tool/linux_arm64/go_bootstrap list -gcflags="" -ldflags="" for [cmd/asm cmd/cgo cmd/compile cmd/link runtime/internal/sys]:
	STALE cmd/asm: stale dependency: internal/cpu
	STALE cmd/cgo: stale dependency: internal/cpu
	STALE cmd/compile: stale dependency: internal/cpu
	STALE cmd/link: stale dependency: internal/cpu
	STALE runtime/internal/sys: build ID mismatch

Command exited with non-zero status 2
```

This is obviously somewhat contrived, using a 32-bit Go toolchain on a 64-bit host for bootstrapping a 64-bit build.... but I also think it should work and don't see what I'm missing.

/cc @ianlancetaylor