cmd/dist: GOHOSTARCH defaults to kernel arch even when it does not match userspace arch #53103
Labels
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
This was first raised in openwrt/packages#18584.
With Raspbian / Raspberry Pi OS and later models of Raspberry Pi, it is possible to boot a 64-bit kernel with an otherwise completely 32-bit userland (by setting
arm_64bit=1
in config.txt).I have replicated this setup with a Raspberry Pi 3 Model B and Raspberry Pi OS Lite (32-bit, based on Debian 11 bullseye):
And I am trying to compile the latest release of Go (1.18.2) using the distro packaged Go (1.15.15) as bootstrap.
What did you expect to see?
Go compiled with no extra flags/environment variables needed.
What did you see instead?
A build error always occurs:
Compilation continues for a while after the runtime/cgo error; it does not appear to be the direct cause of the
go tool dist
error.(I have also seen compilation exit earlier due to an error occurring at the
Building Go toolchain3 using go_bootstrap and Go toolchain2.
stage, though I have not been able to replicate this consistently and am not certain it is related to this issue.)This error appears to be caused by
GOHOSTARCH
defaulting toarm64
(based on the output ofuname -m
) even though the userspace is 32-bit only. If I setGOHOSTARCH=arm
, then compilation succeeds.From the installation documentation it appears that explicitly setting
GOHOSTARCH
is probably necessary/correct, but I wonder: why baseGOHOSTARCH
on the kernel arch whenGOHOSTARCH
from bootstrap Go appears to be a safer default value?The text was updated successfully, but these errors were encountered: