Skip to contentSkip to conversation

meson: fix has_function fork detection (needs suitable include)

PATCH In review Peter Seiderer 1 participant 3 messages Dec 4, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 meson: fix has_function fork detection (needs suitable include)

- fix meson has_function('fork') detection, needs suitable include to avoid false positive (see [1] for details)

Fixes:

.../bootlin-armv7m-uclibc/host/opt/ext-toolchain/arm-buildroot-uclinux-uclibcgnueabi/bin/ld.real: lib/libv4lconvert/libv4lconvert.a(helper.c.o): in function `v4lconvert_helper_decompress':
helper.c:(.text+0x14e): undefined reference to `fork'
collect2: error: ld returned 1 exit status

[1] https://github.com/mesonbuild/meson/issues/7652

---
 meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meson.build +1 -1
index b4018c82..03508bc8 100644
@@ -128,7 +128,7 @@ dep_threads = dependency('threads')
 dep_x11 = dependency('x11', required : false)
 dep_xmlrpc = dependency('xmlrpc', required : false)
 
-have_fork = cc.has_function('fork')
+have_fork = cc.has_function('fork', prefix: '#include <unistd.h>')
 have_i2c_dev = cc.has_header('linux/i2c-dev.h')
 
 if have_visibility
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/2 meson: v4l2grab needs libv4lconvert with fork support enabled

- v4l2grab needs libv4lconvert with fork support enabled

Fixes:

FAILED: contrib/test/v4l2grab
.../bootlin-armv7m-uclibc/host/bin/arm-linux-gcc -o contrib/test/v4l2grab contrib/test/v4l2grab.p/v4l2grab.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,-elf2flt=-r -static -Wl,--start-group lib/libv4l2/libv4l2.a lib/libv4lconvert/libv4lconvert.a -largp -pthread -ldl -lm -lrt -Wl,--end-group .../bootlin-armv7m-uclibc/host/opt/ext-toolchain/arm-buildroot-uclinux-uclibcgnueabi/bin/ld.real: lib/libv4lconvert/libv4lconvert.a(libv4lconvert.c.o): in function `v4lconvert_destroy':
libv4lconvert.c:(.text+0x5c0): undefined reference to `v4lconvert_helper_cleanup'
.../bootlin-armv7m-uclibc/host/opt/ext-toolchain/arm-buildroot-uclinux-uclibcgnueabi/bin/ld.real: lib/libv4lconvert/libv4lconvert.a(libv4lconvert.c.o): in function `v4lconvert_convert_pixfmt':
libv4lconvert.c:(.text+0x1450): undefined reference to `v4lconvert_helper_decompress'
collect2: error: ld returned 1 exit status

---
Notes:
- patch is more or less a quick work around, maybe an better handling of the no-fork-case in libv4lconvert (without v4lconvert_helper_cleanup, v4lconvert_helper_decompress, etc. as they depend on have_fork, see lib/libv4lconvert/meson.build and conditional helper.c compile) is possible???

---
 contrib/test/meson.build | 2 ++
 1 file changed, 2 insertions(+)
contrib/test/meson.build +2 -0
index 29b51df6..c1f40354 100644
@@ -25,6 +25,7 @@ sliced_vbi_detect = executable('sliced-vbi-detect',
                                sliced_vbi_detect_sources,
                                include_directories : v4l2_utils_incdir)
 
+if have_fork
 v4l2grab_sources = files(
     'v4l2grab.c',
 
@@ -41,6 +42,7 @@ v4l2grab = executable('v4l2grab',
                       v4l2grab_sources,
                       dependencies : v4l2grab_deps,
                       include_directories : v4l2_utils_incdir)
+endif
 
 driver_test_sources = files(
     'driver-test.c',
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v4l-utils v1 2/2] meson: v4l2grab needs libv4lconvert with fork support enabled

Hello *,

Quoted 12 lines · Peter Seiderer

- v4l2grab needs libv4lconvert with fork support enabled

Fixes:

FAILED: contrib/test/v4l2grab
.../bootlin-armv7m-uclibc/host/bin/arm-linux-gcc -o contrib/test/v4l2grab contrib/test/v4l2grab.p/v4l2grab.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wl,-elf2flt=-r -static -Wl,--start-group lib/libv4l2/libv4l2.a lib/libv4lconvert/libv4lconvert.a -largp -pthread -ldl -lm -lrt -Wl,--end-group .../bootlin-armv7m-uclibc/host/opt/ext-toolchain/arm-buildroot-uclinux-uclibcgnueabi/bin/ld.real: lib/libv4lconvert/libv4lconvert.a(libv4lconvert.c.o): in function `v4lconvert_destroy':
libv4lconvert.c:(.text+0x5c0): undefined reference to `v4lconvert_helper_cleanup'
.../bootlin-armv7m-uclibc/host/opt/ext-toolchain/arm-buildroot-uclinux-uclibcgnueabi/bin/ld.real: lib/libv4lconvert/libv4lconvert.a(libv4lconvert.c.o): in function `v4lconvert_convert_pixfmt':
libv4lconvert.c:(.text+0x1450): undefined reference to `v4lconvert_helper_decompress'
collect2: error: ld returned 1 exit status

Quoted 8 lines

---
Notes:
- patch is more or less a quick work around, maybe an better handling of the no-fork-case in libv4lconvert (without v4lconvert_helper_cleanup, v4lconvert_helper_decompress, etc. as they depend on have_fork, see lib/libv4lconvert/meson.build and conditional helper.c compile) is possible???

Did find a more suitable solution (?):

lib/libv4lconvert/meson.build +1 -1
index 38740755..4bda5671 100644
@@ -91,7 +91,7 @@ if have_fork
                               include_directories : v4l2_utils_incdir)
 endif
 
-if have_visibility
+if have_visibility and have_fork
     libv4lconvert_c_args += [
       '-fvisibility=hidden',
       '-DHAVE_LIBV4LCONVERT_HELPERS',

Will provide an updated patch (or follow up patch as this one is already applied to git master) soon...

Regards,
Peter

Quoted 24 lines
---
 contrib/test/meson.build | 2 ++
 1 file changed, 2 insertions(+)
contrib/test/meson.build +2 -0
index 29b51df6..c1f40354 100644
@@ -25,6 +25,7 @@ sliced_vbi_detect = executable('sliced-vbi-detect',
                                sliced_vbi_detect_sources,
                                include_directories : v4l2_utils_incdir)
 
+if have_fork
 v4l2grab_sources = files(
     'v4l2grab.c',
 
@@ -41,6 +42,7 @@ v4l2grab = executable('v4l2grab',
                       v4l2grab_sources,
                       dependencies : v4l2grab_deps,
                       include_directories : v4l2_utils_incdir)
+endif
 
 driver_test_sources = files(
     'driver-test.c',