Re: [PATCH v4l-utils v1] v4l2-tracer: fix 'symbol mmap64/open64 is already defined' compile failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Peter,

On 30/03/2023 17:06, Peter Seiderer wrote:
> Compiling for RPi4 (64-bit) using buildroot failes with the following
> error:
> 
>   .../host/bin/aarch64-buildroot-linux-gnu-g++ -DHAVE_CONFIG_H -I. -I../.. -I../../utils/common -I.../aarch64-buildroot-linux-gnu/sysroot/usr/include/json-c -I../../lib/include -Wall -Wpointer-arith -D_GNU_SOURCE -I../../include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g0 -D_FORTIFY_SOURCE=1 -std=gnu++11 -c libv4l2tracer.cpp  -fPIC -DPIC -o .libs/libv4l2tracer_la-libv4l2tracer.o
>   /tmp/ccfbectY.s: Assembler messages:
>   /tmp/ccfbectY.s:208: Error: symbol `open64' is already defined
>   /tmp/ccfbectY.s:762: Error: symbol `mmap64' is already defined
> 
> The preprocessor output shows:
> 
>   [...]
>   extern "C" {
>   # 61 ".../host/aarch64-buildroot-linux-gnu/sysroot/usr/include/sys/mman.h" 3 4
>   extern void * mmap (void *__addr, size_t __len, int __prot, int __flags, int __fd, __off64_t __offset) noexcept (true) __asm__ ("" "mmap64");
>   [...]
>   extern void *mmap64 (void *__addr, size_t __len, int __prot,
>          int __flags, int __fd, __off64_t __offset) noexcept (true);
> 
> And host/aarch64-buildroot-linux-gnu/sysroot/usr/include/sys/mman.h:
> 
>   56 #ifndef __USE_FILE_OFFSET64
>   57 extern void *mmap (void *__addr, size_t __len, int __prot,
>   58                    int __flags, int __fd, __off_t __offset) __THROW;
>   59 #else
>   60 # ifdef __REDIRECT_NTH
>   61 extern void * __REDIRECT_NTH (mmap,
>   62                               (void *__addr, size_t __len, int __prot,
>   63                                int __flags, int __fd, __off64_t __offset),
>   64                               mmap64);
>   65 # else
>   66 #  define mmap mmap64
>   67 # endif
>   68 #endif
>   69 #ifdef __USE_LARGEFILE64
>   70 extern void *mmap64 (void *__addr, size_t __len, int __prot,
>   71                      int __flags, int __fd, __off64_t __offset) __THROW;
>   72 #endif
> 
> Fix it by applying the same undef _LARGEFILE_SOURCE/_FILE_OFFSET_BITS,
> define _LARGEFILE64_SOURCE as in as in lib/libv4l1/v4l1compat.c

If I look at 'man feature_test_macros', then that man page suggests that
_LARGEFILE64_SOURCE is out of date and instead you should use
'#define _FILE_OFFSET_BITS 64'.

Can you test that? If this works, then it should be applied to v4l1compat.c
as well.

> 
> Signed-off-by: Peter Seiderer <ps.report@xxxxxxx>
> ---
> Notes:
> 
>   - maybe the 'defined(linux) && defined(__GLIBC__)' protection
>     present in lib/libv4l1/v4l1compat.c for open64/mmap64 is needed
>     for non glibc compiles of utils/v4l2-tracer/libv4l2tracer.cpp too?

I think we need this too. If nothing else, it is consistent.

Regards,

	Hans

> ---
>  utils/v4l2-tracer/libv4l2tracer.cpp | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/utils/v4l2-tracer/libv4l2tracer.cpp b/utils/v4l2-tracer/libv4l2tracer.cpp
> index a9f039c7..1e3900db 100644
> --- a/utils/v4l2-tracer/libv4l2tracer.cpp
> +++ b/utils/v4l2-tracer/libv4l2tracer.cpp
> @@ -3,6 +3,11 @@
>   * Copyright 2022 Collabora Ltd.
>   */
>  
> +/* ensure we see *64 variants and they aren't transparently used */
> +#undef _LARGEFILE_SOURCE
> +#undef _FILE_OFFSET_BITS
> +#define _LARGEFILE64_SOURCE 1
> +
>  #include "trace.h"
>  #include <dlfcn.h>
>  #include <stdarg.h>




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux