* [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags
@ 2025-02-05 13:58 Fiona Klute via buildroot
2025-02-05 13:58 ` [Buildroot] [PATCH v3 2/3] package/pkg-golang: use ld.bfd instead of ld.gold on aarch64 Fiona Klute via buildroot
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Fiona Klute via buildroot @ 2025-02-05 13:58 UTC (permalink / raw)
To: buildroot
Cc: Nathaniel Roach, yann.morin, Fiona Klute (WIWA),
Christian Stewart, Thomas Perale
From: "Yann E. MORIN" <yann.morin@orange.com>
Currently, only the -static extldflags may be set in the
golang-package infra. However, in some cases, it might be necessary to
pass other flags, either because they are needed on a specific
architecture, or a specific C library; packages may also have a need
to pass arbitrary linker flags when they use CGO linking.
For example, on AArch64, go forcibly uses ld.gold, but it is not
available in all toolchains, and ld.bfd works nowadays (following
patch); another case is musl, where PIE is not supported with go.
Introduce FOO_EXTLDFLAGS, which we use to set those flags, and that
packages can set to pass such flags.
Migrate the current setting of -static to use that new variable.
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Tested-by: Nathaniel Roach <nroach44@nroach44.id.au>
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
Changes v2 -> v3 (Fiona):
* Update commit message as provided by Yann via Buildroot ML
docs/manual/adding-packages-golang.adoc | 6 ++++--
package/pkg-golang.mk | 6 +++++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/docs/manual/adding-packages-golang.adoc b/docs/manual/adding-packages-golang.adoc
index aa25426591..6de0916a83 100644
--- a/docs/manual/adding-packages-golang.adoc
+++ b/docs/manual/adding-packages-golang.adoc
@@ -84,8 +84,10 @@ therefore only use a few of them, or none.
infrastructure will automatically generate a minimal +go.mod+ file
in the package source tree if it doesn't exist.
-* +FOO_LDFLAGS+ and +FOO_TAGS+ can be used to pass respectively the
- +LDFLAGS+ or the +TAGS+ to the +go+ build command.
+* +FOO_LDFLAGS+, +FOO_EXTLDFLAGS+, and +FOO_TAGS+ can be used to pass
+ respectively the go +LDFLAGS+ (via the `-ldflags` command line flag),
+ the external linker flags +EXTLDFLAGS+ (via the `-extldflags`
+ command line flag), or the +TAGS+ to the +go+ build command.
* +FOO_BUILD_TARGETS+ can be used to pass the list of targets that
should be built. If +FOO_BUILD_TARGETS+ is not specified, it
diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
index 33cf9bfb1a..a3421af288 100644
--- a/package/pkg-golang.mk
+++ b/package/pkg-golang.mk
@@ -114,10 +114,14 @@ ifndef $(2)_BUILD_CMDS
ifeq ($(4),target)
ifeq ($(BR2_STATIC_LIBS),y)
-$(2)_LDFLAGS += -extldflags '-static'
+$(2)_EXTLDFLAGS += -static
$(2)_TAGS += osusergo netgo
endif
+ifneq ($$($(2)_EXTLDFLAGS),)
+$(2)_LDFLAGS += -extldflags '$$($(2)_EXTLDFLAGS)'
+endif
+
# Build package for target
define $(2)_BUILD_CMDS
$$(foreach d,$$($(2)_BUILD_TARGETS),\
--
2.47.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Buildroot] [PATCH v3 2/3] package/pkg-golang: use ld.bfd instead of ld.gold on aarch64
2025-02-05 13:58 [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags Fiona Klute via buildroot
@ 2025-02-05 13:58 ` Fiona Klute via buildroot
2025-02-05 14:40 ` yann.morin
2025-02-22 14:32 ` Yann E. MORIN
2025-02-05 13:58 ` [Buildroot] [PATCH v3 3/3] package/containerd: use --no-pie on musl Fiona Klute via buildroot
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Fiona Klute via buildroot @ 2025-02-05 13:58 UTC (permalink / raw)
To: buildroot
Cc: Nathaniel Roach, yann.morin, Fiona Klute (WIWA),
Christian Stewart, Thomas Perale
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
Go forces use of the Gold linker on aarch64 due to a bug in BFD that
is fixed in Binutils >= 2.41 (that includes all versions provided by
Buildroot). Forcing Gold will break with toolchains that don't provide
it (like the Buildroot toolchains), so override the flag and use BFD.
This override should be removed if Go stops forcing Gold, and may have
to be adapted if the set of available linkers changes (e.g. with a
future Binutils update).
See: https://github.com/golang/go/issues/22040
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
Changes v2 -> v3:
* Note in commit message that changes to the override may be required
with Go or Binutils updates
package/pkg-golang.mk | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
index a3421af288..bdf8de4d66 100644
--- a/package/pkg-golang.mk
+++ b/package/pkg-golang.mk
@@ -118,6 +118,16 @@ $(2)_EXTLDFLAGS += -static
$(2)_TAGS += osusergo netgo
endif
+ifeq ($(BR2_aarch64),y)
+# Go forces use of the Gold linker on aarch64 due to a bug in BFD that
+# is fixed in Binutils >= 2.41 (that includes all versions provided by
+# Buildroot). Forcing Gold will break with toolchains that don't
+# provide it (like the Buildroot toolchains), so override the flag and
+# use BFD.
+# See: https://github.com/golang/go/issues/22040
+$(2)_EXTLDFLAGS += -fuse-ld=bfd
+endif
+
ifneq ($$($(2)_EXTLDFLAGS),)
$(2)_LDFLAGS += -extldflags '$$($(2)_EXTLDFLAGS)'
endif
--
2.47.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Buildroot] [PATCH v3 3/3] package/containerd: use --no-pie on musl
2025-02-05 13:58 [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags Fiona Klute via buildroot
2025-02-05 13:58 ` [Buildroot] [PATCH v3 2/3] package/pkg-golang: use ld.bfd instead of ld.gold on aarch64 Fiona Klute via buildroot
@ 2025-02-05 13:58 ` Fiona Klute via buildroot
2025-02-05 14:41 ` yann.morin
2025-02-05 14:39 ` [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags yann.morin
2025-02-05 20:30 ` Christian Stewart via buildroot
3 siblings, 1 reply; 10+ messages in thread
From: Fiona Klute via buildroot @ 2025-02-05 13:58 UTC (permalink / raw)
To: buildroot
Cc: Nathaniel Roach, yann.morin, Fiona Klute (WIWA),
Christian Stewart, Thomas Perale
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
Disable PIE on musl to fix "read-only segment has dynamic relocations"
errors during linking [1] that appeared after major version bump to v2.
[1] https://github.com/golang/go/issues/17847
Fixes: 9c2e146ca9a21f0de3c97981113a57c58c3a5bd5
Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
package/containerd/containerd.mk | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/package/containerd/containerd.mk b/package/containerd/containerd.mk
index ee07c22495..1f70a26ebf 100644
--- a/package/containerd/containerd.mk
+++ b/package/containerd/containerd.mk
@@ -49,6 +49,12 @@ ifneq ($(BR2_PACKAGE_CONTAINERD_CRI),y)
CONTAINERD_TAGS += no_cri
endif
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
+# Go exe build with PIE doesn't work with musl.
+# See: https://github.com/golang/go/issues/17847
+CONTAINERD_EXTLDFLAGS += -Wl,--no-pie
+endif
+
define CONTAINERD_INSTALL_INIT_SYSTEMD
$(INSTALL) -D -m 0644 $(@D)/containerd.service \
$(TARGET_DIR)/usr/lib/systemd/system/containerd.service
--
2.47.2
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags
2025-02-05 13:58 [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags Fiona Klute via buildroot
2025-02-05 13:58 ` [Buildroot] [PATCH v3 2/3] package/pkg-golang: use ld.bfd instead of ld.gold on aarch64 Fiona Klute via buildroot
2025-02-05 13:58 ` [Buildroot] [PATCH v3 3/3] package/containerd: use --no-pie on musl Fiona Klute via buildroot
@ 2025-02-05 14:39 ` yann.morin
2025-02-05 20:30 ` Christian Stewart via buildroot
3 siblings, 0 replies; 10+ messages in thread
From: yann.morin @ 2025-02-05 14:39 UTC (permalink / raw)
To: Fiona Klute; +Cc: Nathaniel Roach, Thomas Perale, Christian Stewart, buildroot
Fiona, All,
On 2025-02-05 14:58 +0100, Fiona Klute spake thusly:
> From: "Yann E. MORIN" <yann.morin@orange.com>
> Currently, only the -static extldflags may be set in the
> golang-package infra. However, in some cases, it might be necessary to
> pass other flags, either because they are needed on a specific
> architecture, or a specific C library; packages may also have a need
> to pass arbitrary linker flags when they use CGO linking.
>
> For example, on AArch64, go forcibly uses ld.gold, but it is not
> available in all toolchains, and ld.bfd works nowadays (following
> patch); another case is musl, where PIE is not supported with go.
>
> Introduce FOO_EXTLDFLAGS, which we use to set those flags, and that
> packages can set to pass such flags.
>
> Migrate the current setting of -static to use that new variable.
>
> Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
> Tested-by: Nathaniel Roach <nroach44@nroach44.id.au>
> Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
Reviewed-by: Yann E. MORIN <yann.morin@orange.com>
Thank you for the rewrite! :-)
Regards,
Yann E. MORIN.
> ---
> Changes v2 -> v3 (Fiona):
> * Update commit message as provided by Yann via Buildroot ML
>
> docs/manual/adding-packages-golang.adoc | 6 ++++--
> package/pkg-golang.mk | 6 +++++-
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/docs/manual/adding-packages-golang.adoc b/docs/manual/adding-packages-golang.adoc
> index aa25426591..6de0916a83 100644
> --- a/docs/manual/adding-packages-golang.adoc
> +++ b/docs/manual/adding-packages-golang.adoc
> @@ -84,8 +84,10 @@ therefore only use a few of them, or none.
> infrastructure will automatically generate a minimal +go.mod+ file
> in the package source tree if it doesn't exist.
>
> -* +FOO_LDFLAGS+ and +FOO_TAGS+ can be used to pass respectively the
> - +LDFLAGS+ or the +TAGS+ to the +go+ build command.
> +* +FOO_LDFLAGS+, +FOO_EXTLDFLAGS+, and +FOO_TAGS+ can be used to pass
> + respectively the go +LDFLAGS+ (via the `-ldflags` command line flag),
> + the external linker flags +EXTLDFLAGS+ (via the `-extldflags`
> + command line flag), or the +TAGS+ to the +go+ build command.
>
> * +FOO_BUILD_TARGETS+ can be used to pass the list of targets that
> should be built. If +FOO_BUILD_TARGETS+ is not specified, it
> diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
> index 33cf9bfb1a..a3421af288 100644
> --- a/package/pkg-golang.mk
> +++ b/package/pkg-golang.mk
> @@ -114,10 +114,14 @@ ifndef $(2)_BUILD_CMDS
> ifeq ($(4),target)
>
> ifeq ($(BR2_STATIC_LIBS),y)
> -$(2)_LDFLAGS += -extldflags '-static'
> +$(2)_EXTLDFLAGS += -static
> $(2)_TAGS += osusergo netgo
> endif
>
> +ifneq ($$($(2)_EXTLDFLAGS),)
> +$(2)_LDFLAGS += -extldflags '$$($(2)_EXTLDFLAGS)'
> +endif
> +
> # Build package for target
> define $(2)_BUILD_CMDS
> $$(foreach d,$$($(2)_BUILD_TARGETS),\
> --
> 2.47.2
>
--
____________
.-----------------.--------------------: _ :------------------.
| Yann E. MORIN | Real-Time Embedded | __/ ) | /"\ ASCII RIBBON |
| | Software Designer | _/ - /' | \ / CAMPAIGN |
| +33 638.411.245 '--------------------: (_ `--, | X AGAINST |
| yann.morin (at) orange.com |_=" ,--' | / \ HTML MAIL |
'--------------------------------------:______/_____:------------------'
____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.
This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Buildroot] [PATCH v3 2/3] package/pkg-golang: use ld.bfd instead of ld.gold on aarch64
2025-02-05 13:58 ` [Buildroot] [PATCH v3 2/3] package/pkg-golang: use ld.bfd instead of ld.gold on aarch64 Fiona Klute via buildroot
@ 2025-02-05 14:40 ` yann.morin
2025-02-22 14:32 ` Yann E. MORIN
1 sibling, 0 replies; 10+ messages in thread
From: yann.morin @ 2025-02-05 14:40 UTC (permalink / raw)
To: Fiona Klute; +Cc: buildroot, Nathaniel Roach, Christian Stewart, Thomas Perale
Fiona, All,
On 2025-02-05 14:58 +0100, Fiona Klute via buildroot spake thusly:
> From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
>
> Go forces use of the Gold linker on aarch64 due to a bug in BFD that
> is fixed in Binutils >= 2.41 (that includes all versions provided by
> Buildroot). Forcing Gold will break with toolchains that don't provide
> it (like the Buildroot toolchains), so override the flag and use BFD.
>
> This override should be removed if Go stops forcing Gold, and may have
> to be adapted if the set of available linkers changes (e.g. with a
> future Binutils update).
Yes, perfect, thanks!
> See: https://github.com/golang/go/issues/22040
>
> Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
Reviewed-by: Yann E. MORIN <yann.morin@orange.com>
Regards,
Yann E. MORIN.
> ---
> Changes v2 -> v3:
> * Note in commit message that changes to the override may be required
> with Go or Binutils updates
>
> package/pkg-golang.mk | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
> index a3421af288..bdf8de4d66 100644
> --- a/package/pkg-golang.mk
> +++ b/package/pkg-golang.mk
> @@ -118,6 +118,16 @@ $(2)_EXTLDFLAGS += -static
> $(2)_TAGS += osusergo netgo
> endif
>
> +ifeq ($(BR2_aarch64),y)
> +# Go forces use of the Gold linker on aarch64 due to a bug in BFD that
> +# is fixed in Binutils >= 2.41 (that includes all versions provided by
> +# Buildroot). Forcing Gold will break with toolchains that don't
> +# provide it (like the Buildroot toolchains), so override the flag and
> +# use BFD.
> +# See: https://github.com/golang/go/issues/22040
> +$(2)_EXTLDFLAGS += -fuse-ld=bfd
> +endif
> +
> ifneq ($$($(2)_EXTLDFLAGS),)
> $(2)_LDFLAGS += -extldflags '$$($(2)_EXTLDFLAGS)'
> endif
> --
> 2.47.2
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
____________
.-----------------.--------------------: _ :------------------.
| Yann E. MORIN | Real-Time Embedded | __/ ) | /"\ ASCII RIBBON |
| | Software Designer | _/ - /' | \ / CAMPAIGN |
| +33 638.411.245 '--------------------: (_ `--, | X AGAINST |
| yann.morin (at) orange.com |_=" ,--' | / \ HTML MAIL |
'--------------------------------------:______/_____:------------------'
____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.
This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Buildroot] [PATCH v3 3/3] package/containerd: use --no-pie on musl
2025-02-05 13:58 ` [Buildroot] [PATCH v3 3/3] package/containerd: use --no-pie on musl Fiona Klute via buildroot
@ 2025-02-05 14:41 ` yann.morin
0 siblings, 0 replies; 10+ messages in thread
From: yann.morin @ 2025-02-05 14:41 UTC (permalink / raw)
To: Fiona Klute; +Cc: Nathaniel Roach, Thomas Perale, Christian Stewart, buildroot
Fiona, All,
On 2025-02-05 14:58 +0100, Fiona Klute spake thusly:
> From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
>
> Disable PIE on musl to fix "read-only segment has dynamic relocations"
> errors during linking [1] that appeared after major version bump to v2.
>
> [1] https://github.com/golang/go/issues/17847
>
> Fixes: 9c2e146ca9a21f0de3c97981113a57c58c3a5bd5
> Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
Reviewed-by: Yann E. MORIN <yann.morin@orange.com>
Regards,
Yann E. MORIN.
> ---
> package/containerd/containerd.mk | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/package/containerd/containerd.mk b/package/containerd/containerd.mk
> index ee07c22495..1f70a26ebf 100644
> --- a/package/containerd/containerd.mk
> +++ b/package/containerd/containerd.mk
> @@ -49,6 +49,12 @@ ifneq ($(BR2_PACKAGE_CONTAINERD_CRI),y)
> CONTAINERD_TAGS += no_cri
> endif
>
> +ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
> +# Go exe build with PIE doesn't work with musl.
> +# See: https://github.com/golang/go/issues/17847
> +CONTAINERD_EXTLDFLAGS += -Wl,--no-pie
> +endif
> +
> define CONTAINERD_INSTALL_INIT_SYSTEMD
> $(INSTALL) -D -m 0644 $(@D)/containerd.service \
> $(TARGET_DIR)/usr/lib/systemd/system/containerd.service
> --
> 2.47.2
>
--
____________
.-----------------.--------------------: _ :------------------.
| Yann E. MORIN | Real-Time Embedded | __/ ) | /"\ ASCII RIBBON |
| | Software Designer | _/ - /' | \ / CAMPAIGN |
| +33 638.411.245 '--------------------: (_ `--, | X AGAINST |
| yann.morin (at) orange.com |_=" ,--' | / \ HTML MAIL |
'--------------------------------------:______/_____:------------------'
____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.
This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags
2025-02-05 13:58 [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags Fiona Klute via buildroot
` (2 preceding siblings ...)
2025-02-05 14:39 ` [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags yann.morin
@ 2025-02-05 20:30 ` Christian Stewart via buildroot
3 siblings, 0 replies; 10+ messages in thread
From: Christian Stewart via buildroot @ 2025-02-05 20:30 UTC (permalink / raw)
To: Fiona Klute
Cc: yann.morin, Thomas Perale, Nathaniel Roach,
Buildroot Mailing List
[-- Attachment #1.1: Type: text/plain, Size: 2996 bytes --]
Hi Fiona,
Looks great!
On Wed, Feb 5, 2025, 5:58 AM Fiona Klute <fiona.klute@gmx.de> wrote:
> From: "Yann E. MORIN" <yann.morin@orange.com>
>
> Currently, only the -static extldflags may be set in the
> golang-package infra. However, in some cases, it might be necessary to
> pass other flags, either because they are needed on a specific
> architecture, or a specific C library; packages may also have a need
> to pass arbitrary linker flags when they use CGO linking.
>
> For example, on AArch64, go forcibly uses ld.gold, but it is not
> available in all toolchains, and ld.bfd works nowadays (following
> patch); another case is musl, where PIE is not supported with go.
>
> Introduce FOO_EXTLDFLAGS, which we use to set those flags, and that
> packages can set to pass such flags.
>
> Migrate the current setting of -static to use that new variable.
>
> Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
> Tested-by: Nathaniel Roach <nroach44@nroach44.id.au>
> Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
> ---
> Changes v2 -> v3 (Fiona):
> * Update commit message as provided by Yann via Buildroot ML
>
> docs/manual/adding-packages-golang.adoc | 6 ++++--
> package/pkg-golang.mk | 6 +++++-
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/docs/manual/adding-packages-golang.adoc
> b/docs/manual/adding-packages-golang.adoc
> index aa25426591..6de0916a83 100644
> --- a/docs/manual/adding-packages-golang.adoc
> +++ b/docs/manual/adding-packages-golang.adoc
> @@ -84,8 +84,10 @@ therefore only use a few of them, or none.
> infrastructure will automatically generate a minimal +go.mod+ file
> in the package source tree if it doesn't exist.
>
> -* +FOO_LDFLAGS+ and +FOO_TAGS+ can be used to pass respectively the
> - +LDFLAGS+ or the +TAGS+ to the +go+ build command.
> +* +FOO_LDFLAGS+, +FOO_EXTLDFLAGS+, and +FOO_TAGS+ can be used to pass
> + respectively the go +LDFLAGS+ (via the `-ldflags` command line flag),
> + the external linker flags +EXTLDFLAGS+ (via the `-extldflags`
> + command line flag), or the +TAGS+ to the +go+ build command.
>
> * +FOO_BUILD_TARGETS+ can be used to pass the list of targets that
> should be built. If +FOO_BUILD_TARGETS+ is not specified, it
> diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
> index 33cf9bfb1a..a3421af288 100644
> --- a/package/pkg-golang.mk
> +++ b/package/pkg-golang.mk
> @@ -114,10 +114,14 @@ ifndef $(2)_BUILD_CMDS
> ifeq ($(4),target)
>
> ifeq ($(BR2_STATIC_LIBS),y)
> -$(2)_LDFLAGS += -extldflags '-static'
> +$(2)_EXTLDFLAGS += -static
> $(2)_TAGS += osusergo netgo
> endif
>
> +ifneq ($$($(2)_EXTLDFLAGS),)
> +$(2)_LDFLAGS += -extldflags '$$($(2)_EXTLDFLAGS)'
> +endif
> +
> # Build package for target
> define $(2)_BUILD_CMDS
> $$(foreach d,$$($(2)_BUILD_TARGETS),\
> --
> 2.47.2
>
Thanks,
Reviewed-by: Christian Stewart <christian@aperture.us>
[-- Attachment #1.2: Type: text/html, Size: 4507 bytes --]
[-- Attachment #2: Type: text/plain, Size: 150 bytes --]
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Buildroot] [PATCH v3 2/3] package/pkg-golang: use ld.bfd instead of ld.gold on aarch64
2025-02-05 13:58 ` [Buildroot] [PATCH v3 2/3] package/pkg-golang: use ld.bfd instead of ld.gold on aarch64 Fiona Klute via buildroot
2025-02-05 14:40 ` yann.morin
@ 2025-02-22 14:32 ` Yann E. MORIN
2025-02-22 17:50 ` Christian Stewart via buildroot
1 sibling, 1 reply; 10+ messages in thread
From: Yann E. MORIN @ 2025-02-22 14:32 UTC (permalink / raw)
To: Fiona Klute; +Cc: buildroot, yann.morin, Christian Stewart
Fiona, All,
On 2025-02-05 14:58 +0100, Fiona Klute via buildroot spake thusly:
> From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
>
> Go forces use of the Gold linker on aarch64 due to a bug in BFD that
> is fixed in Binutils >= 2.41 (that includes all versions provided by
> Buildroot). Forcing Gold will break with toolchains that don't provide
> it (like the Buildroot toolchains), so override the flag and use BFD.
>
> This override should be removed if Go stops forcing Gold, and may have
> to be adapted if the set of available linkers changes (e.g. with a
> future Binutils update).
This patch would fix issues also related to containerd, that we also
see in the autobuilders, e.g.:
http://autobuild.buildroot.org/results/a59/a59bc999e9620ff6b9d97138a2de898aadc07529/build-end.log
[...]/host/bin/aarch64-buildroot-linux-gnu-gcc [...] -fuse-ld=gold [...]
collect2: fatal error: cannot find 'ld'
compilation terminated.
Regards,
Yann E. MORIN.
> See: https://github.com/golang/go/issues/22040
>
> Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
> ---
> Changes v2 -> v3:
> * Note in commit message that changes to the override may be required
> with Go or Binutils updates
>
> package/pkg-golang.mk | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
> index a3421af288..bdf8de4d66 100644
> --- a/package/pkg-golang.mk
> +++ b/package/pkg-golang.mk
> @@ -118,6 +118,16 @@ $(2)_EXTLDFLAGS += -static
> $(2)_TAGS += osusergo netgo
> endif
>
> +ifeq ($(BR2_aarch64),y)
> +# Go forces use of the Gold linker on aarch64 due to a bug in BFD that
> +# is fixed in Binutils >= 2.41 (that includes all versions provided by
> +# Buildroot). Forcing Gold will break with toolchains that don't
> +# provide it (like the Buildroot toolchains), so override the flag and
> +# use BFD.
> +# See: https://github.com/golang/go/issues/22040
> +$(2)_EXTLDFLAGS += -fuse-ld=bfd
> +endif
> +
> ifneq ($$($(2)_EXTLDFLAGS),)
> $(2)_LDFLAGS += -extldflags '$$($(2)_EXTLDFLAGS)'
> endif
> --
> 2.47.2
>
> _______________________________________________
> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Buildroot] [PATCH v3 2/3] package/pkg-golang: use ld.bfd instead of ld.gold on aarch64
2025-02-22 14:32 ` Yann E. MORIN
@ 2025-02-22 17:50 ` Christian Stewart via buildroot
2025-02-22 21:29 ` Romain Naour via buildroot
0 siblings, 1 reply; 10+ messages in thread
From: Christian Stewart via buildroot @ 2025-02-22 17:50 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: Fiona Klute, buildroot, yann.morin
[-- Attachment #1.1: Type: text/plain, Size: 1263 bytes --]
All,
On Sat, Feb 22, 2025 at 6:32 AM Yann E. MORIN <yann.morin.1998@free.fr>
wrote:
> Fiona, All,
>
> On 2025-02-05 14:58 +0100, Fiona Klute via buildroot spake thusly:
> > From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
> >
> > Go forces use of the Gold linker on aarch64 due to a bug in BFD that
> > is fixed in Binutils >= 2.41 (that includes all versions provided by
> > Buildroot). Forcing Gold will break with toolchains that don't provide
> > it (like the Buildroot toolchains), so override the flag and use BFD.
> >
> > This override should be removed if Go stops forcing Gold, and may have
> > to be adapted if the set of available linkers changes (e.g. with a
> > future Binutils update).
>
> This patch would fix issues also related to containerd, that we also
> see in the autobuilders, e.g.:
>
>
> http://autobuild.buildroot.org/results/a59/a59bc999e9620ff6b9d97138a2de898aadc07529/build-end.log
>
> [...]/host/bin/aarch64-buildroot-linux-gnu-gcc [...] -fuse-ld=gold
> [...]
> collect2: fatal error: cannot find 'ld'
> compilation terminated.
>
> Regards,
> Yann E. MORIN.
>
I am seeing these build failures on my end as well and recommend merging
this series.
Best regards,
Christian Stewart
[-- Attachment #1.2: Type: text/html, Size: 1956 bytes --]
[-- Attachment #2: Type: text/plain, Size: 150 bytes --]
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Buildroot] [PATCH v3 2/3] package/pkg-golang: use ld.bfd instead of ld.gold on aarch64
2025-02-22 17:50 ` Christian Stewart via buildroot
@ 2025-02-22 21:29 ` Romain Naour via buildroot
0 siblings, 0 replies; 10+ messages in thread
From: Romain Naour via buildroot @ 2025-02-22 21:29 UTC (permalink / raw)
To: Christian Stewart, Yann E. MORIN; +Cc: Fiona Klute, buildroot, yann.morin
Hello, Fiona, Yann, Christian,
Le 22/02/2025 à 18:50, Christian Stewart via buildroot a écrit :
> All,
>
> On Sat, Feb 22, 2025 at 6:32 AM Yann E. MORIN <yann.morin.1998@free.fr
> <mailto:yann.morin.1998@free.fr>> wrote:
>
> Fiona, All,
>
> On 2025-02-05 14:58 +0100, Fiona Klute via buildroot spake thusly:
> > From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de <mailto:fiona.klute@gmx.de>>
> >
> > Go forces use of the Gold linker on aarch64 due to a bug in BFD that
> > is fixed in Binutils >= 2.41 (that includes all versions provided by
> > Buildroot). Forcing Gold will break with toolchains that don't provide
> > it (like the Buildroot toolchains), so override the flag and use BFD.
> >
> > This override should be removed if Go stops forcing Gold, and may have
> > to be adapted if the set of available linkers changes (e.g. with a
> > future Binutils update).
>
> This patch would fix issues also related to containerd, that we also
> see in the autobuilders, e.g.:
>
> http://autobuild.buildroot.org/results/a59/
> a59bc999e9620ff6b9d97138a2de898aadc07529/build-end.log <http://
> autobuild.buildroot.org/results/a59/
> a59bc999e9620ff6b9d97138a2de898aadc07529/build-end.log>
>
> [...]/host/bin/aarch64-buildroot-linux-gnu-gcc [...] -fuse-ld=gold [...]
> collect2: fatal error: cannot find 'ld'
> compilation terminated.
>
> Regards,
> Yann E. MORIN.
>
>
> I am seeing these build failures on my end as well and recommend merging this
> series.
Applied to master, thanks.
Best regards,
Romain
>
> Best regards,
> Christian Stewart
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-02-22 21:29 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-05 13:58 [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags Fiona Klute via buildroot
2025-02-05 13:58 ` [Buildroot] [PATCH v3 2/3] package/pkg-golang: use ld.bfd instead of ld.gold on aarch64 Fiona Klute via buildroot
2025-02-05 14:40 ` yann.morin
2025-02-22 14:32 ` Yann E. MORIN
2025-02-22 17:50 ` Christian Stewart via buildroot
2025-02-22 21:29 ` Romain Naour via buildroot
2025-02-05 13:58 ` [Buildroot] [PATCH v3 3/3] package/containerd: use --no-pie on musl Fiona Klute via buildroot
2025-02-05 14:41 ` yann.morin
2025-02-05 14:39 ` [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags yann.morin
2025-02-05 20:30 ` Christian Stewart via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox