All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH] package/go: ensure the toolchain is available
Date: Sun, 23 Jun 2024 23:00:40 +0200	[thread overview]
Message-ID: <ZniM-NFO98HzQCxT@landeda> (raw)
In-Reply-To: <20240620182144.3027565-1-yann.morin.1998@free.fr>

All,

On 2024-06-20 20:21 +0200, Yann E. MORIN spake thusly:
> The toolchain is needed to build the final-stage go compiler, when it
> should have CGO support.
> 
> However, in commit 0290c543dec8 (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 commit fa2536ec9401 (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>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
>  package/go/go-src/go-src.mk | 4 +++-
>  package/go/go.mk            | 5 ++++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/package/go/go-src/go-src.mk b/package/go/go-src/go-src.mk
> index 1e061e20bc..0d1a9b3187 100644
> --- a/package/go/go-src/go-src.mk
> +++ b/package/go/go-src/go-src.mk
> @@ -12,7 +12,9 @@ GO_SRC_LICENSE_FILES = LICENSE
>  GO_SRC_CPE_ID_VENDOR = golang
>  
>  HOST_GO_SRC_PROVIDES = host-go
> -HOST_GO_SRC_DEPENDENCIES = host-go-bootstrap-stage3
> +HOST_GO_SRC_DEPENDENCIES = \
> +	host-go-bootstrap-stage3 \
> +	$(HOST_GO_DEPENDENCIES_CGO)
>  
>  ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS),y)
>  
> diff --git a/package/go/go.mk b/package/go/go.mk
> index 6f92893204..91a8fb828f 100644
> --- a/package/go/go.mk
> +++ b/package/go/go.mk
> @@ -83,7 +83,7 @@ HOST_GO_TARGET_ENV = \
>  # any target package needing cgo support must include
>  # 'depends on BR2_TOOLCHAIN_HAS_THREADS' in its config file.
>  ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
> -HOST_GO_DEPENDENCIES += toolchain
> +HOST_GO_DEPENDENCIES_CGO += toolchain
>  HOST_GO_CGO_ENABLED = 1
>  else
>  HOST_GO_CGO_ENABLED = 0
> @@ -95,6 +95,9 @@ else # !BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
>  HOST_GO_CGO_ENABLED = 1
>  endif # BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
>  
> +# Ensure the toolchain is available, whatever the provider
> +HOST_GO_DEPENDENCIES += $(HOST_GO_DEPENDENCIES_CGO)
> +
>  # For the convenience of host golang packages
>  HOST_GO_HOST_ENV = \
>  	$(HOST_GO_COMMON_ENV) \
> -- 
> 2.45.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2024-06-23 21:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 18:21 [Buildroot] [PATCH] package/go: ensure the toolchain is available Yann E. MORIN
2024-06-23 21:00 ` Yann E. MORIN [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZniM-NFO98HzQCxT@landeda \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@buildroot.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.