From: Peter Seiderer <ps.report@gmx.net>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH v4l-utils v1] v4l2-tracer: fix 'symbol mmap64/open64 is already defined' compile failure
Date: Fri, 31 Mar 2023 22:46:08 +0200 [thread overview]
Message-ID: <20230331224608.2e1bf935@gmx.net> (raw)
In-Reply-To: <c7249ba0-f1f4-f199-7a1b-5dde2b79c920@xs4all.nl>
Hello Hans,
On Fri, 31 Mar 2023 10:27:18 +0200, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> 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.
Did you mean as utils/v4l2-tracer/meson.build all ready does:
73 libv4l2_tracer_cpp_args = [
74 # Meson enables large file support unconditionally, which redirects file
75 # operations to 64-bit versions. This results in some symbols being
76 # renamed, for instance open() being renamed to open64(). As the library
77 # needs to provide both 32-bit and 64-bit versions of file operations,
78 # disable transparent large file support.
79 '-U_FILE_OFFSET_BITS',
80 '-D_FILE_OFFSET_BITS=32',
81 '-D_LARGEFILE64_SOURCE',
82 ]
Did my previous test against the 1.24.1 release using the autoconf/automake
build system...
A quick (compile) test for lib/libv4l1/v4l1compat.c with
#undef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 32
#define _LARGEFILE64_SOURCE 1
seems to work...
>
> >
> > Signed-off-by: Peter Seiderer <ps.report@gmx.net>
> > ---
> > 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.
So this patch should be o.k. for the stable-1.24 branch?
Will send one adding the 'defined(linux) && defined(__GLIBC__)' to
v4l2-tracer and one changing the in-file undef/define to the
meson.build solution for lib/libv4l1/v4l1compat.c (in case this
is o.k. here)...
Regards,
Peter
>
> 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>
>
prev parent reply other threads:[~2023-03-31 20:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 15:06 [PATCH v4l-utils v1] v4l2-tracer: fix 'symbol mmap64/open64 is already defined' compile failure Peter Seiderer
2023-03-31 8:27 ` Hans Verkuil
2023-03-31 20:46 ` Peter Seiderer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230331224608.2e1bf935@gmx.net \
--to=ps.report@gmx.net \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox