All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/3] package/multicat: add patch to fix static build
@ 2016-03-19 23:41 Jörg Krause
  2016-03-19 23:41 ` [Buildroot] [PATCH 2/3] package/multicat: add patch to fix musl build Jörg Krause
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jörg Krause @ 2016-03-19 23:41 UTC (permalink / raw)
  To: buildroot

Building multicat in a static context fails with:
  aggregartp.c:381: undefined reference to `pthread_self'

Fix this by adding -lpthread to LDLIBS.

Fixes:
http://autobuild.buildroot.net/results/e69/e699cf6b97bc97f2e8e51aa8b86f0e16af70b5b0/
http://autobuild.buildroot.net/results/201/2019f11dcc43cb0db13ceb4e3a575c1a91573d4c/
http://autobuild.buildroot.net/results/fa9/fa98afec377a1e8fce64af5897d1f7af45804069/
and maybe more.

Upstream status: Pending [1]

[1] https://mailman.videolan.org/pipermail/multicat-devel/2016-March/000125.html

Signed-off-by: J?rg Krause <joerg.krause@embedded.rocks>
---
 package/multicat/0001-Fix-missing-pthread.patch | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 package/multicat/0001-Fix-missing-pthread.patch

diff --git a/package/multicat/0001-Fix-missing-pthread.patch b/package/multicat/0001-Fix-missing-pthread.patch
new file mode 100644
index 0000000..f21c7ce
--- /dev/null
+++ b/package/multicat/0001-Fix-missing-pthread.patch
@@ -0,0 +1,19 @@
+Makefile: link with pthread
+
+Otherwise building multicat in a static context fails:
+  aggregartp.c:381: undefined reference to `pthread_self'
+
+Signed-off-by: J?rg Krause <joerg.krause@embedded.rocks>
+
+diff -purN multicat-2.1.orig/Makefile multicat-2.1/Makefile
+--- multicat-2.1.orig/Makefile	2015-10-05 18:36:29.000000000 +0200
++++ multicat-2.1/Makefile	2016-03-19 21:47:59.467745127 +0100
+@@ -4,7 +4,7 @@ VERSION = 2.1
+ CFLAGS += -Wall -Wformat-security -O3 -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -D_ISOC99_SOURCE -D_BSD_SOURCE
+ CFLAGS += -g
+ # Comment out the following line for Mac OS X build
+-LDLIBS += -lrt
++LDLIBS += -lrt -pthread
+ 
+ OBJ_MULTICAT = multicat.o util.o
+ OBJ_INGESTS = ingests.o util.o
-- 
2.7.4

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

* [Buildroot] [PATCH 2/3] package/multicat: add patch to fix musl build
  2016-03-19 23:41 [Buildroot] [PATCH 1/3] package/multicat: add patch to fix static build Jörg Krause
@ 2016-03-19 23:41 ` Jörg Krause
  2016-03-20 14:11   ` Thomas Petazzoni
  2016-03-19 23:41 ` [Buildroot] [PATCH 3/3] package/multicat: fix build with external Blackfin uClibc toolchain Jörg Krause
  2016-03-20 14:09 ` [Buildroot] [PATCH 1/3] package/multicat: add patch to fix static build Thomas Petazzoni
  2 siblings, 1 reply; 8+ messages in thread
From: Jörg Krause @ 2016-03-19 23:41 UTC (permalink / raw)
  To: buildroot

Add a patch to fix two musl build issues:
  1) `struct udphdr` requires definition of `_GNU_SOURCE`
  2) `mode_t` requires including <sys/types.h>

Fixes:
http://autobuild.buildroot.net/results/9f1/9f1a3f3aab854f1bd20f1064391e613457312022/

Upstream status: Pending [1]

[1] https://mailman.videolan.org/pipermail/multicat-devel/2016-March/000126.html

Signed-off-by: J?rg Krause <joerg.krause@embedded.rocks>
---
 package/multicat/0002-Fix-musl-build.patch | 46 ++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 package/multicat/0002-Fix-musl-build.patch

diff --git a/package/multicat/0002-Fix-musl-build.patch b/package/multicat/0002-Fix-musl-build.patch
new file mode 100644
index 0000000..3a89895
--- /dev/null
+++ b/package/multicat/0002-Fix-musl-build.patch
@@ -0,0 +1,46 @@
+Fix musl build
+
+Defining _GNU_SOURCE is required to get proper member names in `struct udphdr`
+when building against musl. Build error:
+
+  util.c: In function 'RawFillHeaders':
+  util.c:481:9: error: 'struct udphdr' has no member named 'source'
+       udph->source = htons(portsrc);
+           ^
+  util.c:482:9: error: 'struct udphdr' has no member named 'dest'
+       udph->dest   = htons(portdst);
+           ^
+  util.c:483:9: error: 'struct udphdr' has no member named 'len'
+       udph->len    = htons(sizeof(struct udphdr) + len);
+           ^
+  util.c:484:9: error: 'struct udphdr' has no member named 'check'
+       udph->check  = 0;
+
+Including <sys/types.h> in needed for mode_t, otherwise musl build fails:
+  util.h:91:1: error: unknown type name 'mode_t'
+
+Signed-off-by: J?rg Krause <joerg.krause@embedded.rocks>
+
+diff -purN multicat-2.1.orig/util.c multicat-2.1/util.c
+--- multicat-2.1.orig/util.c	2015-07-17 18:03:17.000000000 +0200
++++ multicat-2.1/util.c	2016-03-19 22:21:01.110178772 +0100
+@@ -21,6 +21,8 @@
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+  *****************************************************************************/
+ 
++#define _GNU_SOURCE
++
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <stdint.h>
+diff -purN multicat-2.1.orig/util.h multicat-2.1/util.h
+--- multicat-2.1.orig/util.h	2015-07-15 22:47:39.000000000 +0200
++++ multicat-2.1/util.h	2016-03-19 22:21:58.649834990 +0100
+@@ -21,6 +21,7 @@
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+  *****************************************************************************/
+ 
++#include <sys/types.h>
+ #include <netinet/udp.h>
+ #include <netinet/ip.h>
+ 
-- 
2.7.4

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

* [Buildroot] [PATCH 3/3] package/multicat: fix build with external Blackfin uClibc toolchain
  2016-03-19 23:41 [Buildroot] [PATCH 1/3] package/multicat: add patch to fix static build Jörg Krause
  2016-03-19 23:41 ` [Buildroot] [PATCH 2/3] package/multicat: add patch to fix musl build Jörg Krause
@ 2016-03-19 23:41 ` Jörg Krause
  2016-03-20 14:22   ` Thomas Petazzoni
  2016-03-20 14:09 ` [Buildroot] [PATCH 1/3] package/multicat: add patch to fix static build Thomas Petazzoni
  2 siblings, 1 reply; 8+ messages in thread
From: Jörg Krause @ 2016-03-19 23:41 UTC (permalink / raw)
  To: buildroot

multicat uses clock_nanosleep() conditionally if HAVE_NANOSLEEP is defined. The
bad is that multicat does not check for clock_nanosleep(), but defines
HAVE_NANOSLEEP if __APPLE__ is not defined.

uClibc has clock_nanosleep() only if built with UCLIBC_HAS_ADVANCED_REALTIME.
and the external Blackfin toolchain has no support for clock_nanosleep().

As multicat does not has a configuration setup we add a hook for this toolchain
and undef the macro HAVE_NANOSLEEP in the sources.

Fixes:
http://autobuild.buildroot.net/results/84f/84f8302ee94e6e6849f6b26cb697c2f9986bafe5/
http://autobuild.buildroot.net/results/9e0/9e07a98e87755c992254295c46edb0dace967a21/
http://autobuild.buildroot.net/results/4b0/4b07d276d7c09f2fc2d63c8c37c92519cfe36dbc/
http://autobuild.buildroot.net/results/84f/84f8302ee94e6e6849f6b26cb697c2f9986bafe5/
and many more.

The issue has been reported upstream [1].

[1] https://mailman.videolan.org/pipermail/multicat-devel/2016-March/000127.html

Signed-off-by: J?rg Krause <joerg.krause@embedded.rocks>
---
 package/multicat/multicat.mk | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/package/multicat/multicat.mk b/package/multicat/multicat.mk
index cc6eb78..944cb4c 100644
--- a/package/multicat/multicat.mk
+++ b/package/multicat/multicat.mk
@@ -12,6 +12,18 @@ MULTICAT_LICENSE_FILES = COPYING
 
 MULTICAT_DEPENDENCIES = bitstream
 
+# multicat does not test for HAVE_CLOCK_NANOSLEEP, but sets it if __APPLE__ is
+# not defined. The external Blackfin toolchain is uClibc which has
+# clock_nanosleep() only if built with UCLIBC_HAS_ADVANCED_REALTIME.
+# Use a hool to overwrite the definition of HAVE_CLOCK_NANOSLEEP for this
+# toolchain.
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX),y)
+define MULTICAT_FIXUP_HAVE_CLOCK_NANOSLEEP
+$(SED) 's#define HAVE_CLOCK_NANOSLEEP#undef HAVE_CLOCK_NANOSLEEP#g' $(@D)/util.h
+endef
+MULTICAT_POST_PATCH_HOOKS += MULTICAT_FIXUP_HAVE_CLOCK_NANOSLEEP
+endif
+
 MULTICAT_MAKE_ENV = $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS)
 
 define MULTICAT_BUILD_CMDS
-- 
2.7.4

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

* [Buildroot] [PATCH 1/3] package/multicat: add patch to fix static build
  2016-03-19 23:41 [Buildroot] [PATCH 1/3] package/multicat: add patch to fix static build Jörg Krause
  2016-03-19 23:41 ` [Buildroot] [PATCH 2/3] package/multicat: add patch to fix musl build Jörg Krause
  2016-03-19 23:41 ` [Buildroot] [PATCH 3/3] package/multicat: fix build with external Blackfin uClibc toolchain Jörg Krause
@ 2016-03-20 14:09 ` Thomas Petazzoni
  2 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2016-03-20 14:09 UTC (permalink / raw)
  To: buildroot

J?rg,

On Sun, 20 Mar 2016 00:41:44 +0100, J?rg Krause wrote:
> Building multicat in a static context fails with:
>   aggregartp.c:381: undefined reference to `pthread_self'
> 
> Fix this by adding -lpthread to LDLIBS.
> 
> Fixes:
> http://autobuild.buildroot.net/results/e69/e699cf6b97bc97f2e8e51aa8b86f0e16af70b5b0/
> http://autobuild.buildroot.net/results/201/2019f11dcc43cb0db13ceb4e3a575c1a91573d4c/
> http://autobuild.buildroot.net/results/fa9/fa98afec377a1e8fce64af5897d1f7af45804069/
> and maybe more.
> 
> Upstream status: Pending [1]
> 
> [1] https://mailman.videolan.org/pipermail/multicat-devel/2016-March/000125.html

This info would be useful to have in the patch itself, so I've added it
and applied. Thanks!

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

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

* [Buildroot] [PATCH 2/3] package/multicat: add patch to fix musl build
  2016-03-19 23:41 ` [Buildroot] [PATCH 2/3] package/multicat: add patch to fix musl build Jörg Krause
@ 2016-03-20 14:11   ` Thomas Petazzoni
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2016-03-20 14:11 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 20 Mar 2016 00:41:45 +0100, J?rg Krause wrote:
> Add a patch to fix two musl build issues:
>   1) `struct udphdr` requires definition of `_GNU_SOURCE`
>   2) `mode_t` requires including <sys/types.h>
> 
> Fixes:
> http://autobuild.buildroot.net/results/9f1/9f1a3f3aab854f1bd20f1064391e613457312022/
> 
> Upstream status: Pending [1]
> 
> [1] https://mailman.videolan.org/pipermail/multicat-devel/2016-March/000126.html
> 
> Signed-off-by: J?rg Krause <joerg.krause@embedded.rocks>
> ---
>  package/multicat/0002-Fix-musl-build.patch | 46 ++++++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
>  create mode 100644 package/multicat/0002-Fix-musl-build.patch

Same comment as the previous patch: the information that you have sent
it upstream (with the link) should be added to the patch itself.

Applied with this fixed, thanks!

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

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

* [Buildroot] [PATCH 3/3] package/multicat: fix build with external Blackfin uClibc toolchain
  2016-03-19 23:41 ` [Buildroot] [PATCH 3/3] package/multicat: fix build with external Blackfin uClibc toolchain Jörg Krause
@ 2016-03-20 14:22   ` Thomas Petazzoni
  2016-03-20 17:09     ` Jörg Krause
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2016-03-20 14:22 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 20 Mar 2016 00:41:46 +0100, J?rg Krause wrote:
> multicat uses clock_nanosleep() conditionally if HAVE_NANOSLEEP is defined. The
> bad is that multicat does not check for clock_nanosleep(), but defines

"bad .." ?

> HAVE_NANOSLEEP if __APPLE__ is not defined.
> 
> uClibc has clock_nanosleep() only if built with UCLIBC_HAS_ADVANCED_REALTIME.
> and the external Blackfin toolchain has no support for clock_nanosleep().

Are you sure? Here the Blackfin toolchain does have
UCLIBC_HAS_ADVANCED_REALTIME:

$ grep ADVANCED_REALTIME output/staging/usr/include/bits/uClibc_config.h 
#define __UCLIBC_HAS_ADVANCED_REALTIME__ 1

But indeed it doesn't have clock_nanosleep().

When I saw your patch, I was hoping to be able to replace it with a
patch that tests __UCLIBC__ and __UCLIBC_HAS_ADVANCED_REALTIME__ to
determine whether we have clock_nanosleep() or not. But it seems like
some other things on Blackfin has the consequence that we don't have
clock_nanosleep(). I looked at uClibc 0.9.33.2 (which is used in the
Blackfin toolchain, as far as I can see), and I couldn't see why
clock_nanosleep() was not provided.


> +# multicat does not test for HAVE_CLOCK_NANOSLEEP, but sets it if __APPLE__ is
> +# not defined. The external Blackfin toolchain is uClibc which has
> +# clock_nanosleep() only if built with UCLIBC_HAS_ADVANCED_REALTIME.
> +# Use a hool to overwrite the definition of HAVE_CLOCK_NANOSLEEP for this

hool -> hook

> +# toolchain.
> +ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX),y)
> +define MULTICAT_FIXUP_HAVE_CLOCK_NANOSLEEP
> +$(SED) 's#define HAVE_CLOCK_NANOSLEEP#undef HAVE_CLOCK_NANOSLEEP#g' $(@D)/util.h
> +endef
> +MULTICAT_POST_PATCH_HOOKS += MULTICAT_FIXUP_HAVE_CLOCK_NANOSLEEP
> +endif

I'll be OK to fix this with a hook, but I'd like to understand why we
don't have clock_nanosleep() on Blackfin. It might affect a significant
number of other packages I believe.

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

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

* [Buildroot] [PATCH 3/3] package/multicat: fix build with external Blackfin uClibc toolchain
  2016-03-20 14:22   ` Thomas Petazzoni
@ 2016-03-20 17:09     ` Jörg Krause
  2016-03-20 17:13       ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: Jörg Krause @ 2016-03-20 17:09 UTC (permalink / raw)
  To: buildroot

On So, 2016-03-20 at 15:22 +0100, Thomas Petazzoni wrote:
> Hello,
> 
> On Sun, 20 Mar 2016 00:41:46 +0100, J?rg Krause wrote:
> > 
> > multicat uses clock_nanosleep() conditionally if HAVE_NANOSLEEP is
> > defined. The
> > bad is that multicat does not check for clock_nanosleep(), but
> > defines
> "bad .." ?

Oops, bad English.

> > 
> > HAVE_NANOSLEEP if __APPLE__ is not defined.
> > 
> > uClibc has clock_nanosleep() only if built with
> > UCLIBC_HAS_ADVANCED_REALTIME.
> > and the external Blackfin toolchain has no support for
> > clock_nanosleep().
> Are you sure? Here the Blackfin toolchain does have
> UCLIBC_HAS_ADVANCED_REALTIME:
> 
> $ grep ADVANCED_REALTIME
> output/staging/usr/include/bits/uClibc_config.h?
> #define __UCLIBC_HAS_ADVANCED_REALTIME__ 1
> 
> But indeed it doesn't have clock_nanosleep().

You're right! It has?__UCLIBC_HAS_ADVANCED_REALTIME__, but it does not
define?__UCLIBC_HAS_THREADS_NATIVE__ and clock_nanosleep() is only
defined if both are set in <time.h>:

#??ifdef __UCLIBC_HAS_THREADS_NATIVE__
#???if defined __USE_XOPEN2K && defined
__UCLIBC_HAS_ADVANCED_REALTIME__

extern int clock_nanosleep (clockid_t __clock_id, int __flags,
			????__const struct timespec *__req,
			????struct timespec *__rem);

However the Blackfin toolchain has __LINUXTHREADS_OLD__:
#define __LINUXTHREADS_OLD__ 1

Sorry, my bad!

> 
> When I saw your patch, I was hoping to be able to replace it with a
> patch that tests __UCLIBC__ and __UCLIBC_HAS_ADVANCED_REALTIME__ to
> determine whether we have clock_nanosleep() or not. But it seems like
> some other things on Blackfin has the consequence that we don't have
> clock_nanosleep(). I looked at uClibc 0.9.33.2 (which is used in the
> Blackfin toolchain, as far as I can see), and I couldn't see why
> clock_nanosleep() was not provided.
> 

I'll prepare a v2 with something like that testing for __UCLIBC__,
__UCLIBC_HAS_THREADS_NATIVE__ and __UCLIBC_HAS_ADVANCED_REALTIME__.

> > 
> > +# multicat does not test for HAVE_CLOCK_NANOSLEEP, but sets it if
> > __APPLE__ is
> > +# not defined. The external Blackfin toolchain is uClibc which has
> > +# clock_nanosleep() only if built with
> > UCLIBC_HAS_ADVANCED_REALTIME.
> > +# Use a hool to overwrite the definition of HAVE_CLOCK_NANOSLEEP
> > for this
> hool -> hook
> 
> > 
> > +# toolchain.
> > +ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX),y)
> > +define MULTICAT_FIXUP_HAVE_CLOCK_NANOSLEEP
> > +$(SED) 's#define HAVE_CLOCK_NANOSLEEP#undef
> > HAVE_CLOCK_NANOSLEEP#g' $(@D)/util.h
> > +endef
> > +MULTICAT_POST_PATCH_HOOKS += MULTICAT_FIXUP_HAVE_CLOCK_NANOSLEEP
> > +endif
> I'll be OK to fix this with a hook, but I'd like to understand why we
> don't have clock_nanosleep() on Blackfin. It might affect a
> significant
> number of other packages I believe.

My guess is that uClibc was build with __LINUXTHREADS_OLD__ enabled,
but the toolchain ships libpthread instead. However, I am not a
toolchain expert.

Best regards
J?rg Krause

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

* [Buildroot] [PATCH 3/3] package/multicat: fix build with external Blackfin uClibc toolchain
  2016-03-20 17:09     ` Jörg Krause
@ 2016-03-20 17:13       ` Thomas Petazzoni
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2016-03-20 17:13 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 20 Mar 2016 18:09:47 +0100, J?rg Krause wrote:

> You're right! It has?__UCLIBC_HAS_ADVANCED_REALTIME__, but it does not
> define?__UCLIBC_HAS_THREADS_NATIVE__ and clock_nanosleep() is only
> defined if both are set in <time.h>:
> 
> #??ifdef __UCLIBC_HAS_THREADS_NATIVE__
> #???if defined __USE_XOPEN2K && defined
> __UCLIBC_HAS_ADVANCED_REALTIME__

Ah, makes sense!

> I'll prepare a v2 with something like that testing for __UCLIBC__,
> __UCLIBC_HAS_THREADS_NATIVE__ and __UCLIBC_HAS_ADVANCED_REALTIME__.

Sounds good.

It would of course be better if they were using autoconf, to be able to
add a configure script, but well...

> My guess is that uClibc was build with __LINUXTHREADS_OLD__ enabled,
> but the toolchain ships libpthread instead. However, I am not a
> toolchain expert.

Regardless of whether you have linuxthreads/old, linuxthreads or NPTL,
there is always a library named libpthread. It's the internals of the
library and how it interacts with the kernel that completely differs
between the different implementations.

Best regards,

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

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

end of thread, other threads:[~2016-03-20 17:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-19 23:41 [Buildroot] [PATCH 1/3] package/multicat: add patch to fix static build Jörg Krause
2016-03-19 23:41 ` [Buildroot] [PATCH 2/3] package/multicat: add patch to fix musl build Jörg Krause
2016-03-20 14:11   ` Thomas Petazzoni
2016-03-19 23:41 ` [Buildroot] [PATCH 3/3] package/multicat: fix build with external Blackfin uClibc toolchain Jörg Krause
2016-03-20 14:22   ` Thomas Petazzoni
2016-03-20 17:09     ` Jörg Krause
2016-03-20 17:13       ` Thomas Petazzoni
2016-03-20 14:09 ` [Buildroot] [PATCH 1/3] package/multicat: add patch to fix static build 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.