mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-20 00:50:37 -09:00
The toolchain is needed to build the final-stage go compiler, when it should have CGO support. However, in commit0290c543de(package/go: new subdirectory for go variants), the HOST_GO_DEPENDENCIES assignment was only partially split off to the new location; part of it was left in the ole go.mk to act as common variables. With that commit, the go package had not been renamed, which meant that the dependencies were still correct. But in commitfa2536ec94(package/go: make host package a virtual package), the 'go' package was renamed to 'go-src', and replaced by a 'go' virtual package. The variables in the go-src package were properly renamed, and the variables in the go virtual package were properly _not_ renamed. As a consequence, the go-src package lost its dependency on the toolchain when needed, while the go virtual package still had it. However, that was not correct when CGO is enabled (i.e. when the target has threads): go-src then fails to build: Building Go cmd/dist using [...]/host/lib/go-1.21.8. (go1.21.8 linux/amd64) go tool dist: cannot invoke C compiler ["[...]/host/bin/aarch64-linux-gcc"]: fork/exec [...]/host/bin/aarch64-linux-gcc: no such file or directory Go needs a system C compiler for use with cgo. To set a C compiler, set CC=the-compiler. To disable cgo, set CGO_ENABLED=0. After some retro-thinking, the reasoning behind this was that the toolchain would _also_ be needed when using the prebuilt go-bin, which is indeed correct, so by having it as a dependency of the virtual package, it would ensure the toolchain be present in both cases, when building from scratch or when using a prebuilt go. The oversight being that the toolchain is _also_ needed to actually build go when CGO is enabled. We fix this by handling the toolchain dependency for CGO by exposing it in a variable, that can be used as a dependency in go-src, like is done to actually enable or disable CGO support. We still ensure that host-go still depends on it, for a future go-bin provider. Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>