All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v3 1/6] package/go: Build host tools with host CC
  2016-05-26 18:21 [Buildroot] [PATCH v3 0/6] Fixes for go language support Geoff Levand
@ 2016-05-26 18:21 ` Geoff Levand
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 2/6] package/go: Add HOST_GO_TARGET_ENV Geoff Levand
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Geoff Levand @ 2016-05-26 18:21 UTC (permalink / raw)
  To: buildroot

The go build system doesn't have the notion of cross compiling, but just the
notion of architecture.  When the host and target architectures are different
it expects to be given a target cross compiler in CC_FOR_TARGET.  When the
architectures are the same it will use CC_FOR_TARGET for both host and target
compilation.  To work around this limitation build and install a set of
compiler and tool binaries built with CC_FOR_TARGET set to the host compiler.
Also, the go build system is not compatible with ccache, so use
HOSTCC_NOCCACHE.  See https://github.com/golang/go/issues/11685.

Fixes build errors like these:

  host/usr/bin/go: No such file or directory

  http://autobuild.buildroot.net/results/6664189a6f3a815978e8d0a1d7ef408ca47e2874/

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 package/go/go.mk | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/package/go/go.mk b/package/go/go.mk
index a9e16dd..7ac2540 100644
--- a/package/go/go.mk
+++ b/package/go/go.mk
@@ -35,6 +35,14 @@ endif
 HOST_GO_DEPENDENCIES = host-go-bootstrap
 HOST_GO_ROOT = $(HOST_DIR)/usr/lib/go
 
+# The go build system doesn't have the notion of cross compiling, but just the
+# notion of architecture.  When the host and target architectures are different
+# it expects to be given a target cross compiler in CC_FOR_TARGET.  When the
+# architectures are the same it will use CC_FOR_TARGET for both host and target
+# compilation.  To work around this limitation build and install a set of
+# compiler and tool binaries built with CC_FOR_TARGET set to the host compiler.
+# Also, the go build system is not compatible with ccache, so use
+# HOSTCC_NOCCACHE.  See https://github.com/golang/go/issues/11685.
 HOST_GO_MAKE_ENV = \
 	GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_ROOT) \
 	GOROOT_FINAL=$(HOST_GO_ROOT) \
@@ -44,16 +52,29 @@ HOST_GO_MAKE_ENV = \
 	$(if $(GO_GOARM),GOARM=$(GO_GOARM)) \
 	GOOS=linux \
 	CGO_ENABLED=1 \
+	CC=$(HOSTCC_NOCCACHE)
+
+HOST_GO_TARGET_CC = \
 	CC_FOR_TARGET=$(TARGET_CC) \
 	CXX_FOR_TARGET=$(TARGET_CXX)
 
+HOST_GO_HOST_CC = \
+	CC_FOR_TARGET=$(HOSTCC_NOCCACHE) \
+	CXX_FOR_TARGET=$(HOSTCC_NOCCACHE)
+
+HOST_GO_TMP = $(@D)/host-go-tmp
+
 define HOST_GO_BUILD_CMDS
-	cd $(@D)/src && $(HOST_GO_MAKE_ENV) ./make.bash
+	cd $(@D)/src && $(HOST_GO_MAKE_ENV) $(HOST_GO_HOST_CC) ./make.bash
+	mkdir -p $(HOST_GO_TMP)
+	mv $(@D)/pkg/tool $(HOST_GO_TMP)/
+	mv $(@D)/bin/ $(HOST_GO_TMP)/
+	cd $(@D)/src && $(HOST_GO_MAKE_ENV) $(HOST_GO_TARGET_CC) ./make.bash
 endef
 
 define HOST_GO_INSTALL_CMDS
-	$(INSTALL) -D -m 0755 $(@D)/bin/go $(HOST_GO_ROOT)/bin/go
-	$(INSTALL) -D -m 0755 $(@D)/bin/gofmt $(HOST_GO_ROOT)/bin/gofmt
+	$(INSTALL) -D -m 0755 $(HOST_GO_TMP)/bin/go $(HOST_GO_ROOT)/bin/go
+	$(INSTALL) -D -m 0755 $(HOST_GO_TMP)/bin/gofmt $(HOST_GO_ROOT)/bin/gofmt
 
 	ln -sf ../lib/go/bin/go $(HOST_DIR)/usr/bin/
 	ln -sf ../lib/go/bin/gofmt $(HOST_DIR)/usr/bin/
@@ -62,7 +83,7 @@ define HOST_GO_INSTALL_CMDS
 
 	mkdir -p $(HOST_GO_ROOT)/pkg
 	cp -a $(@D)/pkg/include $(@D)/pkg/linux_* $(HOST_GO_ROOT)/pkg/
-	cp -a $(@D)/pkg/tool $(HOST_GO_ROOT)/pkg/
+	cp -a $(HOST_GO_TMP)/tool $(HOST_GO_ROOT)/pkg/
 
 	# There is a known issue which requires the go sources to be installed
 	# https://golang.org/issue/2775
-- 
2.5.0

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

* [Buildroot] [PATCH v3 2/6] package/go: Add HOST_GO_TARGET_ENV
  2016-05-26 18:21 [Buildroot] [PATCH v3 0/6] Fixes for go language support Geoff Levand
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 1/6] package/go: Build host tools with host CC Geoff Levand
@ 2016-05-26 18:21 ` Geoff Levand
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 6/6] package/go: Set file timestamp Geoff Levand
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Geoff Levand @ 2016-05-26 18:21 UTC (permalink / raw)
  To: buildroot

For the convenience of package makefiles define the new
make variables HOST_GO_TOOLDIR and HOST_GO_TARGET_ENV.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 package/go/go.mk | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/package/go/go.mk b/package/go/go.mk
index 7ac2540..090c5e4 100644
--- a/package/go/go.mk
+++ b/package/go/go.mk
@@ -35,6 +35,15 @@ endif
 HOST_GO_DEPENDENCIES = host-go-bootstrap
 HOST_GO_ROOT = $(HOST_DIR)/usr/lib/go
 
+# For the convienience of target packages.
+HOST_GO_TOOLDIR = $(HOST_GO_ROOT)/pkg/tool/linux_$(GO_GOARCH)
+HOST_GO_TARGET_ENV = \
+	GOARCH=$(GO_GOARCH) \
+	GOROOT="$(HOST_GO_ROOT)" \
+	CC=$(TARGET_CC) \
+	CXX=$(TARGET_CXX) \
+	GOTOOLDIR="$(HOST_GO_TOOLDIR)"
+
 # The go build system doesn't have the notion of cross compiling, but just the
 # notion of architecture.  When the host and target architectures are different
 # it expects to be given a target cross compiler in CC_FOR_TARGET.  When the
-- 
2.5.0

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

* [Buildroot] [PATCH v3 0/6] Fixes for go language support
@ 2016-05-26 18:21 Geoff Levand
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 1/6] package/go: Build host tools with host CC Geoff Levand
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Geoff Levand @ 2016-05-26 18:21 UTC (permalink / raw)
  To: buildroot

Hi,

This series includes a number of fixup for the go language support.  All the
buildbot problems pointed out by Thomas [1] should be resolved by this series.

Please consider all patches in this series to apply to master.

[1] http://lists.busybox.net/pipermail/buildroot/2016-April/159336.html

Changes for V3:
 o Use two step compiler build for all configs.

-Geoff

The following changes since commit b5630ad7125d30cb5d65de49cc2f120bb5cf62ec:

  eudev: link to real homepage (2016-05-26 15:50:01 +0200)

are available in the git repository at:

  git at github.com:glevand/buildroot--buildroot.git for-merge-go-fixes-v3

for you to fetch changes up to a514602fc2cdd03806a41028d9943a7c94cf92b8:

  package/go: Set file timestamp (2016-05-26 11:10:42 -0700)

----------------------------------------------------------------
Geoff Levand (6):
      package/go: Build host tools with host CC
      package/go: Add HOST_GO_TARGET_ENV
      package/flannel: Use HOST_GO_TARGET_ENV
      package/go: Add HOST_GO_CGO_ENABLED
      package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS
      package/go: Set file timestamp

 package/flannel/Config.in  |  4 ++++
 package/flannel/flannel.mk |  2 +-
 package/go/go.mk           | 54 +++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 54 insertions(+), 6 deletions(-)

-- 
2.5.0

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

* [Buildroot] [PATCH v3 5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS
  2016-05-26 18:21 [Buildroot] [PATCH v3 0/6] Fixes for go language support Geoff Levand
                   ` (4 preceding siblings ...)
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 3/6] package/flannel: Use HOST_GO_TARGET_ENV Geoff Levand
@ 2016-05-26 18:21 ` Geoff Levand
  2016-05-26 19:15   ` Thomas Petazzoni
  2016-05-28 13:41   ` Thomas Petazzoni
  2016-05-26 19:14 ` [Buildroot] [PATCH v3 0/6] Fixes for go language support Thomas Petazzoni
  6 siblings, 2 replies; 16+ messages in thread
From: Geoff Levand @ 2016-05-26 18:21 UTC (permalink / raw)
  To: buildroot

flannel uses the cgo package, so needs a toolchain with thread
support.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 package/flannel/Config.in | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/package/flannel/Config.in b/package/flannel/Config.in
index c6a84ef..32d9f66 100644
--- a/package/flannel/Config.in
+++ b/package/flannel/Config.in
@@ -1,6 +1,10 @@
+comment "flannel needs a toolchain w/ threads"
+	depends on !BR2_TOOLCHAIN_HAS_THREADS
+
 config BR2_PACKAGE_FLANNEL
 	bool "flannel"
 	depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
+	depends on BR2_TOOLCHAIN_HAS_THREADS
 	help
 	  Flannel is a virtual network that gives a subnet to each
 	  host for use with container runtimes.
-- 
2.5.0

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

* [Buildroot] [PATCH v3 3/6] package/flannel: Use HOST_GO_TARGET_ENV
  2016-05-26 18:21 [Buildroot] [PATCH v3 0/6] Fixes for go language support Geoff Levand
                   ` (3 preceding siblings ...)
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 4/6] package/go: Add HOST_GO_CGO_ENABLED Geoff Levand
@ 2016-05-26 18:21 ` Geoff Levand
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS Geoff Levand
  2016-05-26 19:14 ` [Buildroot] [PATCH v3 0/6] Fixes for go language support Thomas Petazzoni
  6 siblings, 0 replies; 16+ messages in thread
From: Geoff Levand @ 2016-05-26 18:21 UTC (permalink / raw)
  To: buildroot

Use the newly added HOST_GO_TARGET_ENV variable to pickup the
correct go environment for package builds.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 package/flannel/flannel.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/flannel/flannel.mk b/package/flannel/flannel.mk
index 876efe6..b5f61a0 100644
--- a/package/flannel/flannel.mk
+++ b/package/flannel/flannel.mk
@@ -14,9 +14,9 @@ FLANNEL_LICENSE_FILES = LICENSE
 FLANNEL_DEPENDENCIES = host-go
 
 FLANNEL_MAKE_ENV = \
+	$(HOST_GO_TARGET_ENV) \
 	GOBIN="$(@D)/bin" \
 	GOPATH="$(@D)/gopath" \
-	GOARCH=$(GO_GOARCH) \
 	CGO_ENABLED=1
 
 FLANNEL_GLDFLAGS = \
-- 
2.5.0

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

* [Buildroot] [PATCH v3 6/6] package/go: Set file timestamp
  2016-05-26 18:21 [Buildroot] [PATCH v3 0/6] Fixes for go language support Geoff Levand
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 1/6] package/go: Build host tools with host CC Geoff Levand
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 2/6] package/go: Add HOST_GO_TARGET_ENV Geoff Levand
@ 2016-05-26 18:21 ` Geoff Levand
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 4/6] package/go: Add HOST_GO_CGO_ENABLED Geoff Levand
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Geoff Levand @ 2016-05-26 18:21 UTC (permalink / raw)
  To: buildroot

Set all file timestamps to prevent the go compiler from rebuilding any
built in packages when programs are built.

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 package/go/go.mk | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/package/go/go.mk b/package/go/go.mk
index 095c318..88d2316 100644
--- a/package/go/go.mk
+++ b/package/go/go.mk
@@ -107,6 +107,10 @@ define HOST_GO_INSTALL_CMDS
 	# There is a known issue which requires the go sources to be installed
 	# https://golang.org/issue/2775
 	cp -a $(@D)/src $(HOST_GO_ROOT)/
+
+	# Set all file timestamps to prevent the go compiler from rebuilding any
+	# built in packages when programs are built.
+	find $(HOST_GO_ROOT) -type f -exec touch -r $(HOST_GO_TMP)/bin/go {} \;
 endef
 
 $(eval $(host-generic-package))
-- 
2.5.0

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

* [Buildroot] [PATCH v3 4/6] package/go: Add HOST_GO_CGO_ENABLED
  2016-05-26 18:21 [Buildroot] [PATCH v3 0/6] Fixes for go language support Geoff Levand
                   ` (2 preceding siblings ...)
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 6/6] package/go: Set file timestamp Geoff Levand
@ 2016-05-26 18:21 ` Geoff Levand
  2016-05-26 19:14   ` Thomas Petazzoni
  2017-10-03 10:05   ` Angelo Compagnucci
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 3/6] package/flannel: Use HOST_GO_TARGET_ENV Geoff Levand
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 16+ messages in thread
From: Geoff Levand @ 2016-05-26 18:21 UTC (permalink / raw)
  To: buildroot

The go compiler's cgo support uses threads.  If BR2_TOOLCHAIN_HAS_THREADS is
set, build in cgo support for any go programs that may need it.  Note that
any target package needing cgo support must include
'depends on BR2_TOOLCHAIN_HAS_THREADS' in its config file.

Fixes build errors like these:

  error: #warning requested reentrant code

  http://autobuild.buildroot.net/results/42a8d07101d8d954511d1c884ecb66e8d861899e

Signed-off-by: Geoff Levand <geoff@infradead.org>
---
 package/go/go.mk | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/package/go/go.mk b/package/go/go.mk
index 090c5e4..095c318 100644
--- a/package/go/go.mk
+++ b/package/go/go.mk
@@ -44,6 +44,16 @@ HOST_GO_TARGET_ENV = \
 	CXX=$(TARGET_CXX) \
 	GOTOOLDIR="$(HOST_GO_TOOLDIR)"
 
+# The go compiler's cgo support uses threads.  If BR2_TOOLCHAIN_HAS_THREADS is
+# set, build in cgo support for any go programs that may need it.  Note that
+# 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_CGO_ENABLED = 1
+else
+	HOST_GO_CGO_ENABLED = 0
+endif
+
 # The go build system doesn't have the notion of cross compiling, but just the
 # notion of architecture.  When the host and target architectures are different
 # it expects to be given a target cross compiler in CC_FOR_TARGET.  When the
@@ -60,7 +70,7 @@ HOST_GO_MAKE_ENV = \
 	GOARCH=$(GO_GOARCH) \
 	$(if $(GO_GOARM),GOARM=$(GO_GOARM)) \
 	GOOS=linux \
-	CGO_ENABLED=1 \
+	CGO_ENABLED=$(HOST_GO_CGO_ENABLED) \
 	CC=$(HOSTCC_NOCCACHE)
 
 HOST_GO_TARGET_CC = \
-- 
2.5.0

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

* [Buildroot] [PATCH v3 0/6] Fixes for go language support
  2016-05-26 18:21 [Buildroot] [PATCH v3 0/6] Fixes for go language support Geoff Levand
                   ` (5 preceding siblings ...)
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS Geoff Levand
@ 2016-05-26 19:14 ` Thomas Petazzoni
  6 siblings, 0 replies; 16+ messages in thread
From: Thomas Petazzoni @ 2016-05-26 19:14 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 26 May 2016 18:21:32 +0000, Geoff Levand wrote:

> Geoff Levand (6):
>       package/go: Build host tools with host CC
>       package/go: Add HOST_GO_TARGET_ENV
>       package/flannel: Use HOST_GO_TARGET_ENV
>       package/go: Add HOST_GO_CGO_ENABLED
>       package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS
>       package/go: Set file timestamp

Thanks, I've applied the series. I made a few changes on two patches
(I'll comment on them directly), and I added an additional patch that
adds double quotes around $(TARGET_CC) and $(TARGET_CXX). Indeed, when
ccache support is enabled, those variables contain two words.

Thanks a lot!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH v3 4/6] package/go: Add HOST_GO_CGO_ENABLED
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 4/6] package/go: Add HOST_GO_CGO_ENABLED Geoff Levand
@ 2016-05-26 19:14   ` Thomas Petazzoni
  2017-10-03 10:05   ` Angelo Compagnucci
  1 sibling, 0 replies; 16+ messages in thread
From: Thomas Petazzoni @ 2016-05-26 19:14 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 26 May 2016 18:21:33 +0000, Geoff Levand wrote:

> +# The go compiler's cgo support uses threads.  If BR2_TOOLCHAIN_HAS_THREADS is
> +# set, build in cgo support for any go programs that may need it.  Note that
> +# 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_CGO_ENABLED = 1

Such definitions are normally not indented, so I've fixed this here.

> +else
> +	HOST_GO_CGO_ENABLED = 0

and here.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH v3 5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS Geoff Levand
@ 2016-05-26 19:15   ` Thomas Petazzoni
  2016-05-28 13:41   ` Thomas Petazzoni
  1 sibling, 0 replies; 16+ messages in thread
From: Thomas Petazzoni @ 2016-05-26 19:15 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 26 May 2016 18:21:33 +0000, Geoff Levand wrote:
> flannel uses the cgo package, so needs a toolchain with thread
> support.
> 
> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
>  package/flannel/Config.in | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/package/flannel/Config.in b/package/flannel/Config.in
> index c6a84ef..32d9f66 100644
> --- a/package/flannel/Config.in
> +++ b/package/flannel/Config.in
> @@ -1,6 +1,10 @@
> +comment "flannel needs a toolchain w/ threads"
> +	depends on !BR2_TOOLCHAIN_HAS_THREADS

This also needs:

	depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS

so that the comment doesn't show up on architectures that anyway don't
support Go.

I've fixed that when applying.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH v3 5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS Geoff Levand
  2016-05-26 19:15   ` Thomas Petazzoni
@ 2016-05-28 13:41   ` Thomas Petazzoni
  2016-05-28 15:50     ` Waldemar Brodkorb
  2016-05-31 20:47     ` Geoff Levand
  1 sibling, 2 replies; 16+ messages in thread
From: Thomas Petazzoni @ 2016-05-28 13:41 UTC (permalink / raw)
  To: buildroot

Hello,

On Thu, 26 May 2016 18:21:33 +0000, Geoff Levand wrote:
> flannel uses the cgo package, so needs a toolchain with thread
> support.
> 
> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
>  package/flannel/Config.in | 4 ++++
>  1 file changed, 4 insertions(+)

There are still some issues with the flannel build:

  http://autobuild.buildroot.org/results/d98/d98e1857590738313a293b58f02230539bbaa405/build-end.log

The error is:

/home/buildroot/autobuild/run/instance-2/output/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.9.3/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: cannot find Scrt1.o: No such file or directory

My understanding is that this happens when trying to build PIE binaries
that are statically linked. uClibc does not support that, or at least
not with our current toolchain support. Would it be possible to not
build PIE binaries with Go ? Or alternatively, investigate if it can be
fixed in uClibc ?

Waldemar, maybe you have some input about this problem ?

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH v3 5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS
  2016-05-28 13:41   ` Thomas Petazzoni
@ 2016-05-28 15:50     ` Waldemar Brodkorb
  2016-05-31 20:47     ` Geoff Levand
  1 sibling, 0 replies; 16+ messages in thread
From: Waldemar Brodkorb @ 2016-05-28 15:50 UTC (permalink / raw)
  To: buildroot

Hi,
Thomas Petazzoni wrote,

> Hello,
> 
> On Thu, 26 May 2016 18:21:33 +0000, Geoff Levand wrote:
> > flannel uses the cgo package, so needs a toolchain with thread
> > support.
> > 
> > Signed-off-by: Geoff Levand <geoff@infradead.org>
> > ---
> >  package/flannel/Config.in | 4 ++++
> >  1 file changed, 4 insertions(+)
> 
> There are still some issues with the flannel build:
> 
>   http://autobuild.buildroot.org/results/d98/d98e1857590738313a293b58f02230539bbaa405/build-end.log
> 
> The error is:
> 
> /home/buildroot/autobuild/run/instance-2/output/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.9.3/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: cannot find Scrt1.o: No such file or directory
> 
> My understanding is that this happens when trying to build PIE binaries
> that are statically linked. uClibc does not support that, or at least
> not with our current toolchain support. Would it be possible to not
> build PIE binaries with Go ? Or alternatively, investigate if it can be
> fixed in uClibc ?
> 
> Waldemar, maybe you have some input about this problem ?

Not more then you already told us.
The rule of thumb is: uClibc-ng  + PIE + static = unsupported.

If anyone wnt to work on this, I am happy to include any patches.
But I think some GCC magic must be done for this, too.

best regards
 Waldemar 

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

* [Buildroot] [PATCH v3 5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS
  2016-05-28 13:41   ` Thomas Petazzoni
  2016-05-28 15:50     ` Waldemar Brodkorb
@ 2016-05-31 20:47     ` Geoff Levand
  2016-05-31 20:56       ` Thomas Petazzoni
  1 sibling, 1 reply; 16+ messages in thread
From: Geoff Levand @ 2016-05-31 20:47 UTC (permalink / raw)
  To: buildroot

Hi,

On Sat, 2016-05-28 at 15:41 +0200, Thomas Petazzoni wrote:
> There are still some issues with the flannel build:
> 
>   http://autobuild.buildroot.org/results/d98/d98e1857590738313a293b58f02230539bbaa405/build-end.log
> 
> The error is:
> 
> /home/buildroot/autobuild/run/instance-2/output/host/opt/ext-toolchain/bin/../lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.9.3/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: cannot find Scrt1.o: No such file or directory
> 
> My understanding is that this happens when trying to build PIE binaries
> that are statically linked. uClibc does not support that, or at least
> not with our current toolchain support. Would it be possible to not
> build PIE binaries with Go ? Or alternatively, investigate if it can be
> fixed in uClibc ?

Looking at the go sources, they force -pie when compiling cgo support
for ARM.  See line number 3188 in https://golang.org/src/cmd/go/build.go.

I think the only solution is to not build go packages that use cgo
when BR2_arm && BR2_TOOLCHAIN_USES_UCLIBC, so something like this:

+# cgo on ARM requires PIE linkage, which is not compatable with uClibc.
+comment "flannel is not available with uClibc-based toolchain on ARM architecture"
+       depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
+       depends on BR2_TOOLCHAIN_HAS_THREADS
+       depends on BR2_arm && BR2_TOOLCHAIN_USES_UCLIBC
+
 config BR2_PACKAGE_FLANNEL
        bool "flannel"
        depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
        depends on BR2_TOOLCHAIN_HAS_THREADS
+       depends on !(BR2_arm && BR2_TOOLCHAIN_USES_UCLIBC)
        help

If this looks OK, I'll submit a patch.

-Geoff

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

* [Buildroot] [PATCH v3 5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS
  2016-05-31 20:47     ` Geoff Levand
@ 2016-05-31 20:56       ` Thomas Petazzoni
  2016-06-05  7:00         ` Waldemar Brodkorb
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Petazzoni @ 2016-05-31 20:56 UTC (permalink / raw)
  To: buildroot

Hello,

On Tue, 31 May 2016 13:47:52 -0700, Geoff Levand wrote:

> Looking at the go sources, they force -pie when compiling cgo support
> for ARM.  See line number 3188 in https://golang.org/src/cmd/go/build.go.

Can you get more details than the "get accurate imported sym" the code
has?

> I think the only solution is to not build go packages that use cgo
> when BR2_arm && BR2_TOOLCHAIN_USES_UCLIBC, so something like this:
> 
> +# cgo on ARM requires PIE linkage, which is not compatable with uClibc.
> +comment "flannel is not available with uClibc-based toolchain on ARM architecture"
> +       depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
> +       depends on BR2_TOOLCHAIN_HAS_THREADS
> +       depends on BR2_arm && BR2_TOOLCHAIN_USES_UCLIBC
> +
>  config BR2_PACKAGE_FLANNEL
>         bool "flannel"
>         depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
>         depends on BR2_TOOLCHAIN_HAS_THREADS
> +       depends on !(BR2_arm && BR2_TOOLCHAIN_USES_UCLIBC)
>         help
> 
> If this looks OK, I'll submit a patch.

This is really annoying, as all Go packages that need cgo support will
not work in what is probably Buildroot's most widely used
configuration: ARM with uClibc.

So I'd really like to push things a bit further, and either fix uClibc
so that static+PIE works, or understand why Go wants PIE on ARM.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH v3 5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS
  2016-05-31 20:56       ` Thomas Petazzoni
@ 2016-06-05  7:00         ` Waldemar Brodkorb
  0 siblings, 0 replies; 16+ messages in thread
From: Waldemar Brodkorb @ 2016-06-05  7:00 UTC (permalink / raw)
  To: buildroot

Hi,
Thomas Petazzoni wrote,

> Hello,
> 
> On Tue, 31 May 2016 13:47:52 -0700, Geoff Levand wrote:
> 
> > Looking at the go sources, they force -pie when compiling cgo support
> > for ARM.  See line number 3188 in https://golang.org/src/cmd/go/build.go.
> 
> Can you get more details than the "get accurate imported sym" the code
> has?
> 
> > I think the only solution is to not build go packages that use cgo
> > when BR2_arm && BR2_TOOLCHAIN_USES_UCLIBC, so something like this:
> > 
> > +# cgo on ARM requires PIE linkage, which is not compatable with uClibc.
> > +comment "flannel is not available with uClibc-based toolchain on ARM architecture"
> > +       depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
> > +       depends on BR2_TOOLCHAIN_HAS_THREADS
> > +       depends on BR2_arm && BR2_TOOLCHAIN_USES_UCLIBC
> > +
> >  config BR2_PACKAGE_FLANNEL
> >         bool "flannel"
> >         depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
> >         depends on BR2_TOOLCHAIN_HAS_THREADS
> > +       depends on !(BR2_arm && BR2_TOOLCHAIN_USES_UCLIBC)
> >         help
> > 
> > If this looks OK, I'll submit a patch.
> 
> This is really annoying, as all Go packages that need cgo support will
> not work in what is probably Buildroot's most widely used
> configuration: ARM with uClibc.
> 
> So I'd really like to push things a bit further, and either fix uClibc
> so that static+PIE works, or understand why Go wants PIE on ARM.

A first step would be to integrate Scrt1.o into the external
toolchain packages. It is build when uClibc-ng SHARED is enabled
together with crt1.o.

best regards
 Waldemar

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

* [Buildroot] [PATCH v3 4/6] package/go: Add HOST_GO_CGO_ENABLED
  2016-05-26 18:21 ` [Buildroot] [PATCH v3 4/6] package/go: Add HOST_GO_CGO_ENABLED Geoff Levand
  2016-05-26 19:14   ` Thomas Petazzoni
@ 2017-10-03 10:05   ` Angelo Compagnucci
  1 sibling, 0 replies; 16+ messages in thread
From: Angelo Compagnucci @ 2017-10-03 10:05 UTC (permalink / raw)
  To: buildroot

Dear Geoff, Thomas,

2016-05-26 20:21 GMT+02:00 Geoff Levand <geoff@infradead.org>:
> The go compiler's cgo support uses threads.  If BR2_TOOLCHAIN_HAS_THREADS is
> set, build in cgo support for any go programs that may need it.  Note that
> any target package needing cgo support must include
> 'depends on BR2_TOOLCHAIN_HAS_THREADS' in its config file.
>
> Fixes build errors like these:
>
>   error: #warning requested reentrant code
>
>   http://autobuild.buildroot.net/results/42a8d07101d8d954511d1c884ecb66e8d861899e
>
> Signed-off-by: Geoff Levand <geoff@infradead.org>
> ---
>  package/go/go.mk | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/package/go/go.mk b/package/go/go.mk
> index 090c5e4..095c318 100644
> --- a/package/go/go.mk
> +++ b/package/go/go.mk
> @@ -44,6 +44,16 @@ HOST_GO_TARGET_ENV = \
>         CXX=$(TARGET_CXX) \
>         GOTOOLDIR="$(HOST_GO_TOOLDIR)"
>
> +# The go compiler's cgo support uses threads.  If BR2_TOOLCHAIN_HAS_THREADS is
> +# set, build in cgo support for any go programs that may need it.  Note that
> +# 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_CGO_ENABLED = 1
> +else
> +       HOST_GO_CGO_ENABLED = 0
> +endif

I think this is buggy and should be something like that:

-ifeq (BR2_TOOLCHAIN_HAS_THREADS,y)
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)

Unfortunately, when I apply this fix, the package doesn't compile
anymore. This is the build log:

##### Building packages and commands for linux/arm.
runtime/internal/sys
runtime/internal/atomic
runtime
errors
internal/race
sync/atomic
unicode
unicode/utf8
math
container/list
container/ring
crypto/subtle
crypto/internal/cipherhw
internal/nettrace
runtime/cgo
vendor/golang_org/x/crypto/curve25519
encoding
sync
unicode/utf16
# runtime/cgo
gcc: error: unrecognized command line option '-marm'
image/color
vendor/golang_org/x/crypto/poly1305
internal/syscall/windows
internal/syscall/windows/registry
internal/syscall/windows/sysdll
runtime/race
cmd/compile/internal/test
cmd/vet/internal/whitelist
syscall
io
internal/singleflight
image/color/palette
hash
crypto/cipher
runtime/trace
bytes
strings
hash/adler32
hash/crc32
crypto/hmac
hash/crc64
hash/fnv
strconv
math/rand
math/cmplx
bufio
text/tabwriter
vendor/golang_org/x/text/transform
path
html
reflect
crypto
crypto/aes
crypto/rc4
encoding/base64
encoding/ascii85
encoding/base32
crypto/sha512
crypto/md5
crypto/sha1
crypto/sha256
image
internal/syscall/unix
time
image/internal/imageutil
image/draw
image/jpeg
os
os/signal
fmt
encoding/binary
sort
regexp/syntax
path/filepath
compress/bzip2
container/heap
encoding/pem
runtime/debug
cmd/internal/sys
crypto/des
vendor/golang_org/x/crypto/chacha20poly1305/internal/chacha20
vendor/golang_org/x/crypto/chacha20poly1305
io/ioutil
cmd/internal/dwarf
flag
log
debug/dwarf
compress/flate
debug/gosym
debug/plan9obj
cmd/vendor/golang.org/x/arch/arm/armasm
cmd/vendor/golang.org/x/arch/ppc64/ppc64asm
cmd/vendor/golang.org/x/arch/x86/x86asm
regexp
cmd/internal/obj
archive/tar
compress/zlib
archive/zip
compress/gzip
compress/lzw
context
math/big
debug/elf
debug/macho
debug/pe
encoding/hex
database/sql/driver
encoding/csv
encoding/gob
cmd/internal/goobj
encoding/json
encoding/xml
database/sql
vendor/golang_org/x/net/http2/hpack
vendor/golang_org/x/net/idna
vendor/golang_org/x/text/unicode/norm
cmd/internal/objfile
vendor/golang_org/x/text/width
crypto/dsa
crypto/elliptic
encoding/asn1
cmd/addr2line
crypto/rand
mime
mime/quotedprintable
crypto/rsa
crypto/ecdsa
crypto/x509/pkix
net/http/internal
net/url
go/token
text/template/parse
os/exec
text/scanner
image/gif
go/scanner
go/constant
image/png
index/suffixarray
internal/pprof/profile
testing
internal/trace
go/ast
net/internal/socktest
testing/iotest
testing/quick
text/template
cmd/internal/obj/arm
cmd/internal/obj/arm64
cmd/internal/obj/mips
cmd/internal/obj/ppc64
internal/testenv
cmd/internal/obj/s390x
go/parser
go/printer
runtime/pprof/internal/protopprof
cmd/internal/obj/x86
runtime/pprof
go/doc
html/template
testing/internal/testdeps
cmd/asm/internal/flags
go/types
cmd/asm/internal/lex
go/format
cmd/internal/bio
go/build
cmd/cgo
cmd/compile/internal/syntax
cmd/internal/gcprog
cmd/internal/browser
cmd/dist
cmd/fix
cmd/gofmt
cmd/asm/internal/arch
cmd/compile/internal/ssa
cmd/asm/internal/asm
cmd/cover
cmd/doc
cmd/link/internal/ld
cmd/asm
cmd/nm
cmd/objdump
cmd/pack
cmd/pprof/internal/plugin
go/internal/gccgoimporter
go/internal/gcimporter
cmd/api
cmd/pprof/internal/report
cmd/pprof/internal/svg
cmd/pprof/internal/tempfile
cmd/pprof/internal/symbolizer
go/importer
cmd/pprof/internal/symbolz
cmd/vet/internal/cfg
cmd/vet
cmd/pprof/internal/commands
cmd/pprof/internal/driver
cmd/link/internal/arm
cmd/link/internal/arm64
cmd/link/internal/amd64
cmd/link/internal/mips
cmd/link/internal/mips64
cmd/link/internal/ppc64
cmd/link/internal/s390x
cmd/link/internal/x86
cmd/link
cmd/compile/internal/gc
cmd/compile/internal/amd64
cmd/compile/internal/arm
cmd/compile/internal/arm64
cmd/compile/internal/mips
cmd/compile/internal/mips64
cmd/compile/internal/ppc64
cmd/compile/internal/s390x
cmd/compile/internal/x86
cmd/compile
package/pkg-generic.mk:234: recipe for target
'/media/angelo/WD/data/BUILDROOT/br_qemu_arm/build/host-go-1.8.3/.stamp_built'
failed
make[1]: *** [/media/angelo/WD/data/BUILDROOT/br_qemu_arm/build/host-go-1.8.3/.stamp_built]
Error 2


Geoff, have you any advice on how to debug the go build process?
Unfortunately, I've not found anything like a log file that could help
me.

Sincerely, Angelo



> +
>  # The go build system doesn't have the notion of cross compiling, but just the
>  # notion of architecture.  When the host and target architectures are different
>  # it expects to be given a target cross compiler in CC_FOR_TARGET.  When the
> @@ -60,7 +70,7 @@ HOST_GO_MAKE_ENV = \
>         GOARCH=$(GO_GOARCH) \
>         $(if $(GO_GOARM),GOARM=$(GO_GOARM)) \
>         GOOS=linux \
> -       CGO_ENABLED=1 \
> +       CGO_ENABLED=$(HOST_GO_CGO_ENABLED) \
>         CC=$(HOSTCC_NOCCACHE)
>
>  HOST_GO_TARGET_CC = \
> --
> 2.5.0
>
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot



-- 
Profile: http://it.linkedin.com/in/compagnucciangelo

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

end of thread, other threads:[~2017-10-03 10:05 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-26 18:21 [Buildroot] [PATCH v3 0/6] Fixes for go language support Geoff Levand
2016-05-26 18:21 ` [Buildroot] [PATCH v3 1/6] package/go: Build host tools with host CC Geoff Levand
2016-05-26 18:21 ` [Buildroot] [PATCH v3 2/6] package/go: Add HOST_GO_TARGET_ENV Geoff Levand
2016-05-26 18:21 ` [Buildroot] [PATCH v3 6/6] package/go: Set file timestamp Geoff Levand
2016-05-26 18:21 ` [Buildroot] [PATCH v3 4/6] package/go: Add HOST_GO_CGO_ENABLED Geoff Levand
2016-05-26 19:14   ` Thomas Petazzoni
2017-10-03 10:05   ` Angelo Compagnucci
2016-05-26 18:21 ` [Buildroot] [PATCH v3 3/6] package/flannel: Use HOST_GO_TARGET_ENV Geoff Levand
2016-05-26 18:21 ` [Buildroot] [PATCH v3 5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS Geoff Levand
2016-05-26 19:15   ` Thomas Petazzoni
2016-05-28 13:41   ` Thomas Petazzoni
2016-05-28 15:50     ` Waldemar Brodkorb
2016-05-31 20:47     ` Geoff Levand
2016-05-31 20:56       ` Thomas Petazzoni
2016-06-05  7:00         ` Waldemar Brodkorb
2016-05-26 19:14 ` [Buildroot] [PATCH v3 0/6] Fixes for go language support Thomas Petazzoni

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.