* [Buildroot] [PATCH v1 1/1] package/go: add toolchain as dependency of host-go
@ 2023-07-28 5:25 Christian Stewart via buildroot
2023-07-28 7:26 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 4+ messages in thread
From: Christian Stewart via buildroot @ 2023-07-28 5:25 UTC (permalink / raw)
To: buildroot; +Cc: Christian Stewart, Yann E . MORIN, Thomas Petazzoni
Running "make host-go" in a clean Buildroot tree causes a build failure:
Building Go cmd/dist using /host/lib/go-1.19.10. (go1.19.10 linux/amd64)
go tool dist: cannot invoke C compiler ["/host/bin/arm-linux-gcc"]:
fork/exec /host/bin/arm-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.
Despite the fact that we're compiling the Go compiler and not compiling anything
for the target system, the Go compiler make.bash still attempts to call the
target C compiler during the build process.
The dependency on toolchain is necessary only for host-go and not the other
host-go-bootstrap packages as we only pass the path to the target compiler to
the final host-go compiler package make.bash.
Fix the issue by adding toolchain to the host-go package dependencies.
Signed-off-by: Christian Stewart <christian@aperture.us>
---
package/go/go.mk | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/package/go/go.mk b/package/go/go.mk
index efa47e5781..ada343f766 100644
--- a/package/go/go.mk
+++ b/package/go/go.mk
@@ -12,7 +12,8 @@ GO_LICENSE = BSD-3-Clause
GO_LICENSE_FILES = LICENSE
GO_CPE_ID_VENDOR = golang
-HOST_GO_DEPENDENCIES = host-go-bootstrap-stage2
+# Go requires the target toolchain to build the compiler.
+HOST_GO_DEPENDENCIES = host-go-bootstrap-stage2 toolchain
HOST_GO_GOPATH = $(HOST_DIR)/share/go-path
HOST_GO_HOST_CACHE = $(HOST_DIR)/share/host-go-cache
HOST_GO_ROOT = $(HOST_DIR)/lib/go
--
2.41.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Buildroot] [PATCH v1 1/1] package/go: add toolchain as dependency of host-go
2023-07-28 5:25 [Buildroot] [PATCH v1 1/1] package/go: add toolchain as dependency of host-go Christian Stewart via buildroot
@ 2023-07-28 7:26 ` Thomas Petazzoni via buildroot
2023-07-29 1:19 ` Christian Stewart via buildroot
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-07-28 7:26 UTC (permalink / raw)
To: Christian Stewart; +Cc: Yann E . MORIN, buildroot
Hello Christian,
On Thu, 27 Jul 2023 22:25:30 -0700
Christian Stewart <christian@aperture.us> wrote:
> Running "make host-go" in a clean Buildroot tree causes a build failure:
>
> Building Go cmd/dist using /host/lib/go-1.19.10. (go1.19.10 linux/amd64)
> go tool dist: cannot invoke C compiler ["/host/bin/arm-linux-gcc"]:
> fork/exec /host/bin/arm-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.
>
> Despite the fact that we're compiling the Go compiler and not compiling anything
> for the target system, the Go compiler make.bash still attempts to call the
> target C compiler during the build process.
>
> The dependency on toolchain is necessary only for host-go and not the other
> host-go-bootstrap packages as we only pass the path to the target compiler to
> the final host-go compiler package make.bash.
>
> Fix the issue by adding toolchain to the host-go package dependencies.
>
> Signed-off-by: Christian Stewart <christian@aperture.us>
> ---
> package/go/go.mk | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/package/go/go.mk b/package/go/go.mk
> index efa47e5781..ada343f766 100644
> --- a/package/go/go.mk
> +++ b/package/go/go.mk
> @@ -12,7 +12,8 @@ GO_LICENSE = BSD-3-Clause
> GO_LICENSE_FILES = LICENSE
> GO_CPE_ID_VENDOR = golang
>
> -HOST_GO_DEPENDENCIES = host-go-bootstrap-stage2
> +# Go requires the target toolchain to build the compiler.
> +HOST_GO_DEPENDENCIES = host-go-bootstrap-stage2 toolchain
What happens when we're building host-go for a target architecture that
Go does not support? This was previously supported in host-go, in which
we have this condition:
ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS),y)
...
endif
to ensure we build a host-go compiler capable of building code for the
target if the target is supported, but in all cases builds a Go
compiler capable of compiling code for the host. Indeed, host-go might
also be needed solely to build host utilities, which would be relevant
even if the target architecture isn't supported by Go.
Best regards,
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Buildroot] [PATCH v1 1/1] package/go: add toolchain as dependency of host-go
2023-07-28 7:26 ` Thomas Petazzoni via buildroot
@ 2023-07-29 1:19 ` Christian Stewart via buildroot
2023-07-29 21:05 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 4+ messages in thread
From: Christian Stewart via buildroot @ 2023-07-29 1:19 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: Yann E . MORIN, buildroot
Hi Thomas,
On Fri, Jul 28, 2023 at 12:27 AM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
> What happens when we're building host-go for a target architecture that
> Go does not support? This was previously supported in host-go, in which
> we have this condition:
>
> ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS),y)
> ...
> endif
>
> to ensure we build a host-go compiler capable of building code for the
> target if the target is supported, but in all cases builds a Go
> compiler capable of compiling code for the host. Indeed, host-go might
> also be needed solely to build host utilities, which would be relevant
> even if the target architecture isn't supported by Go.
I suppose if you don't set CC_FOR_TARGET nor CXX_FOR_TARGET then the
Go compiler will simply use CC and CXX which are HOSTCC_NOCCACHE and
HOSTCXX_NOCCACHE.
I noticed there's already a line which adds toolchain as a dependency
if cgo is enabled.
Will mark this patch as not applicable for now and consider why the
build failed in the TestMender test case when running "make host-go"
without building the toolchain first. I guess that's a case where cgo
is not enabled and yet BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS=y.
We should move the toolchain dependency to be if
BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS instead of if Cgo is enabled,
I think.
best,
Christian
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Buildroot] [PATCH v1 1/1] package/go: add toolchain as dependency of host-go
2023-07-29 1:19 ` Christian Stewart via buildroot
@ 2023-07-29 21:05 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-07-29 21:05 UTC (permalink / raw)
To: Christian Stewart; +Cc: Yann E . MORIN, buildroot
On Fri, 28 Jul 2023 18:19:46 -0700
Christian Stewart <christian@aperture.us> wrote:
> > to ensure we build a host-go compiler capable of building code for the
> > target if the target is supported, but in all cases builds a Go
> > compiler capable of compiling code for the host. Indeed, host-go might
> > also be needed solely to build host utilities, which would be relevant
> > even if the target architecture isn't supported by Go.
>
> I suppose if you don't set CC_FOR_TARGET nor CXX_FOR_TARGET then the
> Go compiler will simply use CC and CXX which are HOSTCC_NOCCACHE and
> HOSTCXX_NOCCACHE.
It'd be nicer to have more certainty than "I suppose" :-)
> I noticed there's already a line which adds toolchain as a dependency
> if cgo is enabled.
Hu, where is that?
> Will mark this patch as not applicable for now and consider why the
> build failed in the TestMender test case when running "make host-go"
> without building the toolchain first. I guess that's a case where cgo
> is not enabled and yet BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS=y.
>
> We should move the toolchain dependency to be if
> BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS instead of if Cgo is enabled,
> I think.
Possibly, and this would make sense, if indeed Go needs the target
C/C++ compiler to build the target Go stuff.
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-29 21:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-28 5:25 [Buildroot] [PATCH v1 1/1] package/go: add toolchain as dependency of host-go Christian Stewart via buildroot
2023-07-28 7:26 ` Thomas Petazzoni via buildroot
2023-07-29 1:19 ` Christian Stewart via buildroot
2023-07-29 21:05 ` Thomas Petazzoni via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox