Skip to contentSkip to conversation

libv4l: add patches to fix musl build issues, and enable on musl

PATCH New Thomas Petazzoni 3 participants 6 messages Dec 1, 2015 – Dec 18, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libv4l: add patches to fix musl build issues, and enable on musl

This commit adds two patches to the libv4l package, the first one fixes the __off_t usage and the second one fixes locale-related function usage. Those two patches allow libv4l to build fine against musl, so we remove the dependency of glibc || uclibc.

---
 ...scall-priv.h-Use-off_t-instead-of-__off_t.patch | 108 +++++++++++++++++++++
 ...rly-use-ENABLE_NLS-for-locale-related-cod.patch | 107 ++++++++++++++++++++
 package/libv4l/Config.in                           |   7 +-
 3 files changed, 217 insertions(+), 5 deletions(-)
 create mode 100644 package/libv4l/0003-libv4lsyscall-priv.h-Use-off_t-instead-of-__off_t.patch
 create mode 100644 package/libv4l/0004-utils-Properly-use-ENABLE_NLS-for-locale-related-cod.patch
package/libv4l/0003-libv4lsyscall-priv.h-Use-off_t-instead-of-__off_t.patch new file +108 -0
new file mode 100644
index 0000000..015acd4
@@ -0,0 +1,108 @@
+From 87369a8d190a182ee087cec5164e4c9586b0d80e Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Wed, 28 Oct 2015 09:27:47 +0100
+Subject: [PATCH] libv4lsyscall-priv.h: Use off_t instead of __off_t
+
+__off_t is a kernel internal symbol, which happens to be user-visible
+with glibc, but not necessarily with other C libraries such as
+musl. In v4l-utils code, it's mainly used for the mmap() prototype,
+but the mmap() manpage really uses off_t, not __off_t.
+
+Switching from __off_t to off_t allows the code to build properly with
+musl.
+
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ lib/libv4l1/v4l1compat.c               |  3 +--
+ lib/libv4l2/v4l2convert.c              |  5 ++---
+ lib/libv4lconvert/libv4lsyscall-priv.h | 11 +++--------
+ 3 files changed, 6 insertions(+), 13 deletions(-)
+
+diff --git a/lib/libv4l1/v4l1compat.c b/lib/libv4l1/v4l1compat.c
+index 97e8c4e..e5c9e56 100644
+--- a/lib/libv4l1/v4l1compat.c
++++ b/lib/libv4l1/v4l1compat.c
+@@ -29,7 +29,6 @@
+ #include <stdarg.h>
+ #include <fcntl.h>
+ #include <libv4l1.h>
+-#include "../libv4lconvert/libv4lsyscall-priv.h" /* for __off_t */
+ 
+ #include <sys/ioctl.h>
+ #include <sys/mman.h>
+@@ -119,7 +118,7 @@ LIBV4L_PUBLIC ssize_t read(int fd, void *buffer, size_t n)
+ }
+ 
+ LIBV4L_PUBLIC void *mmap(void *start, size_t length, int prot, int flags, int fd,
+-		__off_t offset)
++		off_t offset)
+ {
+ 	return v4l1_mmap(start, length, prot, flags, fd, offset);
+ }
+diff --git a/lib/libv4l2/v4l2convert.c b/lib/libv4l2/v4l2convert.c
+index a6dc30e..7b7e253 100644
+--- a/lib/libv4l2/v4l2convert.c
++++ b/lib/libv4l2/v4l2convert.c
+@@ -39,7 +39,6 @@
+ #include <string.h>
+ #include <sys/ioctl.h>
+ #include <sys/mman.h>
+-#include "../libv4lconvert/libv4lsyscall-priv.h"
+ #include <linux/videodev2.h>
+ #include <libv4l2.h>
+ 
+@@ -151,14 +150,14 @@ LIBV4L_PUBLIC ssize_t read(int fd, void *buffer, size_t n)
+ }
+ 
+ LIBV4L_PUBLIC void *mmap(void *start, size_t length, int prot, int flags, int fd,
+-		__off_t offset)
++		off_t offset)
+ {
+ 	return v4l2_mmap(start, length, prot, flags, fd, offset);
+ }
+ 
+ #if defined(linux) && defined(__GLIBC__)
+ LIBV4L_PUBLIC void *mmap64(void *start, size_t length, int prot, int flags, int fd,
+-		__off64_t offset)
++		off64_t offset)
+ {
+ 	return v4l2_mmap(start, length, prot, flags, fd, offset);
+ }
+diff --git a/lib/libv4lconvert/libv4lsyscall-priv.h b/lib/libv4lconvert/libv4lsyscall-priv.h
+index f548fb2..f87eff4 100644
+--- a/lib/libv4lconvert/libv4lsyscall-priv.h
++++ b/lib/libv4lconvert/libv4lsyscall-priv.h
+@@ -59,11 +59,6 @@
+ #define	_IOC_SIZE(cmd) IOCPARM_LEN(cmd)
+ #define	MAP_ANONYMOUS MAP_ANON
+ #define	MMAP2_PAGE_SHIFT 0
+-typedef off_t __off_t;
+-#endif
+-
+-#if defined(ANDROID)
+-typedef off_t __off_t;
+ #endif
+ 
+ #undef SYS_OPEN
+@@ -95,15 +90,15 @@ typedef off_t __off_t;
+ #if defined(__FreeBSD__)
+ #define SYS_MMAP(addr, len, prot, flags, fd, off) \
+ 	__syscall(SYS_mmap, (void *)(addr), (size_t)(len), \
+-			(int)(prot), (int)(flags), (int)(fd), (__off_t)(off))
++			(int)(prot), (int)(flags), (int)(fd), (off_t)(off))
+ #elif defined(__FreeBSD_kernel__)
+ #define SYS_MMAP(addr, len, prot, flags, fd, off) \
+ 	syscall(SYS_mmap, (void *)(addr), (size_t)(len), \
+-			(int)(prot), (int)(flags), (int)(fd), (__off_t)(off))
++			(int)(prot), (int)(flags), (int)(fd), (off_t)(off))
+ #else
+ #define SYS_MMAP(addr, len, prot, flags, fd, off) \
+ 	syscall(SYS_mmap2, (void *)(addr), (size_t)(len), \
+-			(int)(prot), (int)(flags), (int)(fd), (__off_t)((off) >> MMAP2_PAGE_SHIFT))
++			(int)(prot), (int)(flags), (int)(fd), (off_t)((off) >> MMAP2_PAGE_SHIFT))
+ #endif
+ 
+ #define SYS_MUNMAP(addr, len) \
+-- 
+2.6.2
+
package/libv4l/0004-utils-Properly-use-ENABLE_NLS-for-locale-related-cod.patch new file +107 -0

107 lines not on this page · raw message

package/libv4l/Config.in +2 -5
index 16dc6bb..078a8c9 100644
@@ -5,8 +5,6 @@ config BR2_PACKAGE_LIBV4L
 	depends on !BR2_STATIC_LIBS # dlopen()
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0 # media headers
-	# wait for libv4l 1.7+ for musl compatibility
-	depends on BR2_TOOLCHAIN_USES_GLIBC || BR2_TOOLCHAIN_USES_UCLIBC
 	select BR2_PACKAGE_ARGP_STANDALONE if BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_MUSL
 	select BR2_PACKAGE_LIBICONV if !BR2_ENABLE_LOCALE
 	help
@@ -40,8 +38,7 @@ config BR2_PACKAGE_LIBV4L_UTILS
 
 endif
 
-comment "libv4l needs an uClibc or (e)glibc toolchain w/ threads, dynamic library, C++ and headers >= 3.0"
+comment "libv4l needs a toolchain w/ threads, dynamic library, C++ and headers >= 3.0"
 	depends on BR2_USE_MMU
 	depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS \
-		|| !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0 \
-		|| !(BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC)
+		|| !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0
Signature · 1 line
2.6.3
#1 lore raw

PATCH 1/2 libv4l: add patches to fix musl build issues, and enable on musl

Hello,

Quoted 5 lines · Thomas Petazzoni

This commit adds two patches to the libv4l package, the first one fixes the __off_t usage and the second one fixes locale-related function usage. Those two patches allow libv4l to build fine against musl, so we remove the dependency of glibc || uclibc.

Quoted 8 lines
---
 ...scall-priv.h-Use-off_t-instead-of-__off_t.patch | 108 +++++++++++++++++++++
 ...rly-use-ENABLE_NLS-for-locale-related-cod.patch | 107 ++++++++++++++++++++
 package/libv4l/Config.in                           |   7 +-
 3 files changed, 217 insertions(+), 5 deletions(-)
 create mode 100644 package/libv4l/0003-libv4lsyscall-priv.h-Use-off_t-instead-of-__off_t.patch
 create mode 100644 package/libv4l/0004-utils-Properly-use-ENABLE_NLS-for-locale-related-cod.patch

Since nobody reviewed, ACKed or NAKed, I applied this patch.

Thomas

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

PATCH 2/2 v4l2grab: new package

In reply to Thomas Petazzoni

From: Volkov Viacheslav <[email protected]>

[Thomas:
- remove dependency on musl, since libv4l can now be built without musl
- add missing Config.in comment for the toolchain dependencies
- add hash file.
- rework commit log.
- expand Config.in help text.]

---
 package/Config.in              |  1 +
 package/v4l2grab/Config.in     | 20 ++++++++++++++++++++
 package/v4l2grab/v4l2grab.hash |  2 ++
 package/v4l2grab/v4l2grab.mk   | 15 +++++++++++++++
 4 files changed, 38 insertions(+)
 create mode 100644 package/v4l2grab/Config.in
 create mode 100644 package/v4l2grab/v4l2grab.hash
 create mode 100644 package/v4l2grab/v4l2grab.mk
package/Config.in +1 -0
index 2bdad01..a6049c4 100644
@@ -40,6 +40,7 @@ menu "Audio and video applications"
 	source "package/tstools/Config.in"
 	source "package/twolame/Config.in"
 	source "package/upmpdcli/Config.in"
+	source "package/v4l2grab/Config.in"
 	source "package/vlc/Config.in"
 	source "package/vorbis-tools/Config.in"
 	source "package/wavpack/Config.in"
package/v4l2grab/Config.in new file +20 -0
new file mode 100644
index 0000000..ec3a7a8
@@ -0,0 +1,20 @@
+config BR2_PACKAGE_V4L2GRAB
+	bool "v4l2grab"
+	depends on BR2_TOOLCHAIN_HAS_THREADS # libv4l
+	depends on BR2_USE_MMU # libv4l
+	depends on !BR2_STATIC_LIBS # libv4l
+	depends on BR2_INSTALL_LIBSTDCPP # libv4l
+	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0 # libv4l
+	select BR2_PACKAGE_JPEG
+	select BR2_PACKAGE_LIBV4L
+	help
+	  Utility for grabbing JPEGs form V4L2 devices. This tool is
+	  similar to v4l2grab available from libv4l contrib directory,
+	  but provides additional features such as JPEG output.
+
+	  http://www.twam.info/software/v4l2grab-grabbing-jpegs-from-v4l2-devices
+
+comment "v4l2grab needs a toolchain w/ threads, dynamic library, C++ and headers >= 3.0"
+	depends on BR2_USE_MMU
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS \
+		|| !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0
package/v4l2grab/v4l2grab.hash new file +2 -0
new file mode 100644
index 0000000..e0a1797
@@ -0,0 +1,2 @@
+# Locally calculated
+sha256 5d635dde1a83bd81a84584a62581ea4b17eb462be8a5e1ec04a7a019f3cf1791 v4l2grab-7815752fafb8b797047e819a08a3b6e2f2880846.tar.gz
package/v4l2grab/v4l2grab.mk new file +15 -0
new file mode 100644
index 0000000..12b4c3f
@@ -0,0 +1,15 @@
+################################################################################
+#
+# v4l2grab
+#
+################################################################################
+
+V4L2GRAB_VERSION = 7815752fafb8b797047e819a08a3b6e2f2880846
+V4L2GRAB_SITE = $(call github,twam,v4l2grab,$(V4L2GRAB_VERSION))
+V4L2GRAB_LICENSE = GPLv2+
+V4L2GRAB_LICENSE_FILE = LICENSE
+# Fetched from github, no pre-generated configure script provided
+V4L2GRAB_AUTORECONF = YES
+V4L2GRAB_DEPENDENCIES = libjpeg libv4l
+
+$(eval $(autotools-package))
Signature · 1 line
2.6.3
#3 lore raw

PATCH 2/2 v4l2grab: new package

Quoted 12 lines · Thomas Petazzoni

From: Volkov Viacheslav <[email protected]>

[Thomas:
- remove dependency on musl, since libv4l can now be built without musl
- add missing Config.in comment for the toolchain dependencies
- add hash file.
- rework commit log.
- expand Config.in help text.]

[snip]

package/v4l2grab/v4l2grab.mk line 10

Quoted 12 lines

+++ b/package/v4l2grab/v4l2grab.mk

package/v4l2grab/v4l2grab.mk new file +10 -0
@@ -0,0 +1,15 @@
+################################################################################
+#
+# v4l2grab
+#
+################################################################################
+
+V4L2GRAB_VERSION = 7815752fafb8b797047e819a08a3b6e2f2880846
+V4L2GRAB_SITE = $(call github,twam,v4l2grab,$(V4L2GRAB_VERSION))
+V4L2GRAB_LICENSE = GPLv2+
+V4L2GRAB_LICENSE_FILE = LICENSE

I only see LICENSE.md in the repository. Oh, that's because it changed name
just two days ago. Perhaps it would be a good idea to bump to 0abed72532bee02e545a1924b6883c839d50febf now and fix the license file name, since it will most likely be forgotten in the next bump.

Regards,
Arnout

package/v4l2grab/v4l2grab.mk line 13

Quoted 3 lines
package/v4l2grab/v4l2grab.mk new file +3 -0
+# Fetched from github, no pre-generated configure script provided
+V4L2GRAB_AUTORECONF = YES
+V4L2GRAB_DEPENDENCIES = libjpeg libv4l

You select BR2_PACKAGE_JPEG, not BR2_PACKAGE_LIBJPEG, so you should depend on
jpeg instead of libjpeg.

With that fixed you can add my

Regards,
Arnout

Quoted 3 lines
(quoted diff) +2 -0
+
+$(eval $(autotools-package))
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#4 lore raw

PATCH 2/2 v4l2grab: new package

In reply to Thomas Petazzoni

From: Volkov Viacheslav <[email protected]>

change version and license

[Thomas:
- remove dependency on musl, since libv4l can now be built without musl
- add missing Config.in comment for the toolchain dependencies
- add hash file.
- rework commit log.
- expand Config.in help text.]

---
 package/Config.in              |  1 +
 package/v4l2grab/Config.in     | 20 ++++++++++++++++++++
 package/v4l2grab/v4l2grab.hash |  2 ++
 package/v4l2grab/v4l2grab.mk   | 15 +++++++++++++++
 4 files changed, 38 insertions(+)
 create mode 100644 package/v4l2grab/Config.in
 create mode 100644 package/v4l2grab/v4l2grab.hash
 create mode 100644 package/v4l2grab/v4l2grab.mk
package/Config.in +1 -0
index 2bdad01..a6049c4 100644
@@ -40,6 +40,7 @@ menu "Audio and video applications"
 	source "package/tstools/Config.in"
 	source "package/twolame/Config.in"
 	source "package/upmpdcli/Config.in"
+	source "package/v4l2grab/Config.in"
 	source "package/vlc/Config.in"
 	source "package/vorbis-tools/Config.in"
 	source "package/wavpack/Config.in"
package/v4l2grab/Config.in new file +20 -0
new file mode 100644
index 0000000..ec3a7a8
@@ -0,0 +1,20 @@
+config BR2_PACKAGE_V4L2GRAB
+	bool "v4l2grab"
+	depends on BR2_TOOLCHAIN_HAS_THREADS # libv4l
+	depends on BR2_USE_MMU # libv4l
+	depends on !BR2_STATIC_LIBS # libv4l
+	depends on BR2_INSTALL_LIBSTDCPP # libv4l
+	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0 # libv4l
+	select BR2_PACKAGE_JPEG
+	select BR2_PACKAGE_LIBV4L
+	help
+	  Utility for grabbing JPEGs form V4L2 devices. This tool is
+	  similar to v4l2grab available from libv4l contrib directory,
+	  but provides additional features such as JPEG output.
+
+	  http://www.twam.info/software/v4l2grab-grabbing-jpegs-from-v4l2-devices
+
+comment "v4l2grab needs a toolchain w/ threads, dynamic library, C++ and headers >= 3.0"
+	depends on BR2_USE_MMU
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS \
+		|| !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_0
package/v4l2grab/v4l2grab.hash new file +2 -0
new file mode 100644
index 0000000..e0a1797
@@ -0,0 +1,2 @@
+# Locally calculated
+sha256 568d51512107226dab1ac809ab1ed4d544ce3f8f505b62c3b2177fb643c8157b v4l2grab-0abed72532bee02e545a1924b6883c839d50febf.tar.gz
package/v4l2grab/v4l2grab.mk new file +15 -0
new file mode 100644
index 0000000..12b4c3f
@@ -0,0 +1,15 @@
+################################################################################
+#
+# v4l2grab
+#
+################################################################################
+
+V4L2GRAB_VERSION = 0abed72532bee02e545a1924b6883c839d50febf
+V4L2GRAB_SITE = $(call github,twam,v4l2grab,$(V4L2GRAB_VERSION))
+V4L2GRAB_LICENSE = GPLv2+
+V4L2GRAB_LICENSE_FILE = LICENSE.md
+# Fetched from github, no pre-generated configure script provided
+V4L2GRAB_AUTORECONF = YES
+V4L2GRAB_DEPENDENCIES = libjpeg libv4l
+
+$(eval $(autotools-package))

-- 2.6.3

#5 lore raw

PATCH 2/2 v4l2grab: new package

Hello,

I've applied, but there were still two remaining issues. See below.

Quoted 14 lines · Viacheslav Volkov
package/v4l2grab/v4l2grab.hash new file +2 -0
new file mode 100644
index 0000000..e0a1797
@@ -0,0 +1,2 @@
+# Locally calculated
+sha256 568d51512107226dab1ac809ab1ed4d544ce3f8f505b62c3b2177fb643c8157b v4l2grab-0abed72532bee02e545a1924b6883c839d50febf.tar.gz
package/v4l2grab/v4l2grab.mk new file +0 -0
new file mode 100644
index 0000000..12b4c3f

package/v4l2grab/v4l2grab.mk line 10

Quoted 10 lines
package/v4l2grab/v4l2grab.mk new file +10 -0
@@ -0,0 +1,15 @@
+################################################################################
+#
+# v4l2grab
+#
+################################################################################
+
+V4L2GRAB_VERSION = 0abed72532bee02e545a1924b6883c839d50febf
+V4L2GRAB_SITE = $(call github,twam,v4l2grab,$(V4L2GRAB_VERSION))
+V4L2GRAB_LICENSE = GPLv2+
+V4L2GRAB_LICENSE_FILE = LICENSE.md

This variable should have been named V4L2GRAB_LICENSE_FILES.

package/v4l2grab/v4l2grab.mk line 13

Quoted 3 lines
package/v4l2grab/v4l2grab.mk new file +3 -0
+# Fetched from github, no pre-generated configure script provided
+V4L2GRAB_AUTORECONF = YES
+V4L2GRAB_DEPENDENCIES = libjpeg libv4l

And as noted by Arnout, we should not depend on libjpeg, but on jpeg.

I've fixed those two issues before applying.

Thanks!

Thomas

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