Skip to contentSkip to conversation

package/multicat: add patch to fix static build

PATCH New Jörg Krause 2 participants 8 messages Mar 19, 2016 – Mar 20, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 package/multicat: add patch to fix static build

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

---
 package/multicat/0001-Fix-missing-pthread.patch | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 package/multicat/0001-Fix-missing-pthread.patch
package/multicat/0001-Fix-missing-pthread.patch new file +19 -0
new file mode 100644
index 0000000..f21c7ce
@@ -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 <[email protected]>
+
+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
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/3 package/multicat: add patch to fix musl build

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

---
 package/multicat/0002-Fix-musl-build.patch | 46 ++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 package/multicat/0002-Fix-musl-build.patch
package/multicat/0002-Fix-musl-build.patch new file +46 -0
new file mode 100644
index 0000000..3a89895
@@ -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 <[email protected]>
+
+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>
+ 
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/3 package/multicat: add patch to fix musl build

Hello,

Quoted 9 lines · J?rg Krause

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]

Quoted 7 lines

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

---
 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

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

PATCH 3/3 package/multicat: fix build with external Blackfin uClibc toolchain

In reply to Jörg Krause

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

---
 package/multicat/multicat.mk | 12 ++++++++++++
 1 file changed, 12 insertions(+)
package/multicat/multicat.mk +12 -0
index cc6eb78..944cb4c 100644
@@ -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
Signature · 1 line
2.7.4
#4 lore raw

PATCH 3/3 package/multicat: fix build with external Blackfin uClibc toolchain

Hello,

Quoted 2 lines · J?rg Krause

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

"bad .." ?

Quoted 4 lines

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.

package/multicat/multicat.mk MULTICAT_LICENSE_FILES = COPYING · line 18

Quoted 4 lines
package/multicat/multicat.mk +4 -0
+# 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

package/multicat/multicat.mk MULTICAT_LICENSE_FILES = COPYING · line 25

Quoted 7 lines
package/multicat/multicat.mk +7 -0
+# 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

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#5 lore raw

PATCH 3/3 package/multicat: fix build with external Blackfin uClibc toolchain

Quoted 9 lines · Thomas Petazzoni

Hello,

Quoted 5 lines · J?rg Krause

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.

Quoted 7 lines
Quoted 7 lines

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().

Quoted 8 lines

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!

Quoted 9 lines

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__.

Quoted 11 lines
Quoted 8 lines

+# multicat does not test for HAVE_CLOCK_NANOSLEEP, but sets it if __APPLE__ is

(quoted diff) +2 -0
+# 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

Quoted 1 line
Quoted 12 lines

package/multicat/multicat.mk MULTICAT_LICENSE_FILES = COPYING · line 25

Quoted 8 lines
package/multicat/multicat.mk +4 -0
+# 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

package/multicat/multicat.mk +3 -0
+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

#6 lore raw

PATCH 3/3 package/multicat: fix build with external Blackfin uClibc toolchain

Hello,

Quoted 7 lines · J?rg Krause

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!

Quoted 2 lines

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...

Quoted 3 lines

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

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#7 lore raw

PATCH 1/3 package/multicat: add patch to fix static build

In reply to Jörg Krause

J?rg,

Quoted 11 lines · J?rg Krause

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.

Quoted 3 lines

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

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