Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: yann.morin@orange.com
To: Fiona Klute <fiona.klute@gmx.de>
Cc: Nathaniel Roach <nroach44@nroach44.id.au>,
	Thomas Perale <thomas.perale@mind.be>,
	Christian Stewart <christian@aperture.us>,
	buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags
Date: Wed, 5 Feb 2025 15:39:38 +0100	[thread overview]
Message-ID: <Z6N4KpdTeYI3pRck@yd-6wlzhs3> (raw)
In-Reply-To: <20250205135825.2310972-1-fiona.klute@gmx.de>

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

  parent reply	other threads:[~2025-02-05 14:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` yann.morin [this message]
2025-02-05 20:30 ` [Buildroot] [PATCH v3 1/3] package/pkg-golang: allow packages to provide extldflags Christian Stewart via buildroot

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=Z6N4KpdTeYI3pRck@yd-6wlzhs3 \
    --to=yann.morin@orange.com \
    --cc=buildroot@buildroot.org \
    --cc=christian@aperture.us \
    --cc=fiona.klute@gmx.de \
    --cc=nroach44@nroach44.id.au \
    --cc=thomas.perale@mind.be \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox