diff mbox

[v3,5/6] package/flannel: Add BR2_TOOLCHAIN_HAS_THREADS

Message ID 627469f0b7b4e604da3a5ab3ef721f138a1c95a8.1464286518.git.geoff@infradead.org
State Accepted
Headers show

Commit Message

Geoff Levand May 26, 2016, 6:21 p.m. UTC
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(+)

Comments

Thomas Petazzoni May 26, 2016, 7:15 p.m. UTC | #1
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 May 28, 2016, 1:41 p.m. UTC | #2
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
Waldemar Brodkorb May 28, 2016, 3:50 p.m. UTC | #3
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
Geoff Levand May 31, 2016, 8:47 p.m. UTC | #4
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
Thomas Petazzoni May 31, 2016, 8:56 p.m. UTC | #5
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
Waldemar Brodkorb June 5, 2016, 7 a.m. UTC | #6
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
diff mbox

Patch

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.