Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] pkg-golang: add strip, asmflags, gcflags support
@ 2019-01-24  8:18 Christian Stewart
  2019-01-24  9:08 ` Anisse Astier
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Stewart @ 2019-01-24  8:18 UTC (permalink / raw)
  To: buildroot

Adding package-level variables to set asmflags, gcflags.

Conditionally sets ldflags -s -w when buildroot is configured to strip binaries.

Signed-off-by: Christian Stewart <christian@paral.in>
---
 package/pkg-golang.mk | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
index 4f2c7e77e1..79ebec94be 100644
--- a/package/pkg-golang.mk
+++ b/package/pkg-golang.mk
@@ -55,7 +55,15 @@ ifeq ($(BR2_STATIC_LIBS),y)
 $(2)_LDFLAGS += -extldflags '-static'
 endif
 
+ifeq ($(BR2_STRIP_strip),y)
+$(2)_LDFLAGS += -s -w
+endif
+
+$(2)_ASMFLAGS += -trimpath=$(BUILD_DIR)
+$(2)_GCFLAGS  += -trimpath=$(BUILD_DIR)
 $(2)_BUILD_OPTS += \
+	-asmflags "$$($(2)_ASMFLAGS)" \
+	-gcflags "$$($(2)_GCFLAGS)" \
 	-ldflags "$$($(2)_LDFLAGS)" \
 	-tags "$$($(2)_TAGS)" \
 	-p $(PARALLEL_JOBS)
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH 1/1] pkg-golang: add strip, asmflags, gcflags support
  2019-01-24  8:18 [Buildroot] [PATCH 1/1] pkg-golang: add strip, asmflags, gcflags support Christian Stewart
@ 2019-01-24  9:08 ` Anisse Astier
  2019-01-25  2:16   ` Christian Stewart
  0 siblings, 1 reply; 3+ messages in thread
From: Anisse Astier @ 2019-01-24  9:08 UTC (permalink / raw)
  To: buildroot

On Thu, Jan 24, 2019 at 12:18:34AM -0800, Christian Stewart wrote:
> Adding package-level variables to set asmflags, gcflags.
> 
> Conditionally sets ldflags -s -w when buildroot is configured to strip binaries.
> 
> Signed-off-by: Christian Stewart <christian@paral.in>
> ---
>  package/pkg-golang.mk | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
> index 4f2c7e77e1..79ebec94be 100644
> --- a/package/pkg-golang.mk
> +++ b/package/pkg-golang.mk
> @@ -55,7 +55,15 @@ ifeq ($(BR2_STATIC_LIBS),y)
>  $(2)_LDFLAGS += -extldflags '-static'
>  endif
>  
> +ifeq ($(BR2_STRIP_strip),y)
> +$(2)_LDFLAGS += -s -w
> +endif
> +
> +$(2)_ASMFLAGS += -trimpath=$(BUILD_DIR)
> +$(2)_GCFLAGS  += -trimpath=$(BUILD_DIR)

I see that you added trimpath here, which is useful for removing the
build path from the binaries, (and having reproducible builds), but it
isn't mentionned in the commit message.

As a sidenote, it seems that this option is broken when building a
package with go modules:
https://github.com/golang/go/issues/28008

Regards,

Anisse

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH 1/1] pkg-golang: add strip, asmflags, gcflags support
  2019-01-24  9:08 ` Anisse Astier
@ 2019-01-25  2:16   ` Christian Stewart
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Stewart @ 2019-01-25  2:16 UTC (permalink / raw)
  To: buildroot

Anisse,

Anisse Astier <anisse@astier.eu> writes:
> I see that you added trimpath here, which is useful for removing the
> build path from the binaries, (and having reproducible builds), but it
> isn't mentionned in the commit message.

Yes, I had originally intended for this to be a separate commit, but the
functionality works as intended and I am happy to keep it as part of
this commmit.

> As a sidenote, it seems that this option is broken when building a
> package with go modules:
> https://github.com/golang/go/issues/28008

There will never be a Buildroot core package with Go modules in use nor
enabled, as this would imply a separate network resource fetching
mechanism from the core Buildroot tarball download + hash cycle.

Even so, the option would then not break the build, but would merely
fail to trim the paths in the output binary.

Best,
Christian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-25  2:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-24  8:18 [Buildroot] [PATCH 1/1] pkg-golang: add strip, asmflags, gcflags support Christian Stewart
2019-01-24  9:08 ` Anisse Astier
2019-01-25  2:16   ` Christian Stewart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox