Message ID | d8f84ccfa3285d30e3b4195b7ea0ddffb18c6512.1698657764.git.yann.morin@orange.com |
---|---|
State | Changes Requested |
Headers | show |
Series | [1/2] package/pkg-golang: allow packages to provide extldflags | expand |
On 30/10/23 17:22, yann.morin@orange.com wrote: > From: "Yann E. MORIN" <yann.morin@orange.com> > > For some packages, it may be necessary to pass extra extldflags. For > example, some packages will need to be able to specify what ld to use, > and so will need to pass -fuse-ld={bfd,gold} as extldflags. > > Introduce FOO_EXTLDFLAGS, that packages can set to pass such flags. > > Signed-off-by: Yann E. MORIN <yann.morin@orange.com> > --- > 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 c952cde577..c238050096 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 7ba82284f3..ba49ce153e 100644 > --- a/package/pkg-golang.mk > +++ b/package/pkg-golang.mk > @@ -101,10 +101,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),\ Tested-by: Nathaniel Roach <nroach44@nroach44.id.au>
diff --git a/docs/manual/adding-packages-golang.adoc b/docs/manual/adding-packages-golang.adoc index c952cde577..c238050096 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 7ba82284f3..ba49ce153e 100644 --- a/package/pkg-golang.mk +++ b/package/pkg-golang.mk @@ -101,10 +101,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),\