[libcamera-devel] [PATCH] libcamera: add dependencies to libcamera_dep

Fabrice Fontaine fontaine.fabrice at gmail.com
Wed Jun 2 22:55:58 CEST 2021


Le mer. 2 juin 2021 à 22:27, Laurent Pinchart
<laurent.pinchart at ideasonboard.com> a écrit :
>
> Bonsoir Fabrice,
>
> On Wed, Jun 02, 2021 at 09:38:46PM +0200, Fabrice Fontaine wrote:
> > Le mer. 2 juin 2021 à 02:59, Laurent Pinchart a écrit :
> > > On Tue, Jun 01, 2021 at 10:51:54PM +0200, Fabrice Fontaine wrote:
> > > > Add dependencies to libcamera_dep to avoid the following build failure
> > > > with qcam on sparc v8 which is raised since commit
> > > > a8310248fc26cc1e1b791af5e9394c1d20bee269:
> > > >
> > > > FAILED: src/qcam/qcam
> > > > /srv/storage/autobuild/run/instance-0/output-1/host/bin/sparc-linux-g++  -o src/qcam/qcam src/qcam/qcam.p/meson-generated_.._qt5-feathericons_qrc.cpp.o src/qcam/qcam.p/meson-generated_moc_main_window.cpp.o src/qcam/qcam.p/meson-generated_moc_viewfinder_qt.cpp.o src/qcam/qcam.p/.._cam_options.cpp.o src/qcam/qcam.p/.._cam_stream_options.cpp.o src/qcam/qcam.p/format_converter.cpp.o src/qcam/qcam.p/main.cpp.o src/qcam/qcam.p/main_window.cpp.o src/qcam/qcam.p/message_handler.cpp.o src/qcam/qcam.p/viewfinder_qt.cpp.o src/qcam/qcam.p/dng_writer.cpp.o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -Wshadow -include config.h '-Wl,-rpath,$ORIGIN/../libcamera' -Wl,-rpath-link,/srv/storage/autobuild/run/instance-0/output-1/build/libcamera-3a1f67a8031ac5ad96a11d5dc8b2e8976290497b/build/src/libcamera -Wl,--start-group src/libcamera/libcamera.so /srv/storage/autobuild/run/instance-0/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Core.so /srv/storage/autobuild/run/instance-0/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Gui.so /srv/storage/autobuild/run/instance-0/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Widgets.so /srv/storage/autobuild/run/instance-0/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libtiff.so -Wl,--end-group
> > > > /srv/storage/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/9.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: src/qcam/qcam.p/main_window.cpp.o: undefined reference to symbol '__atomic_fetch_add_4@@LIBATOMIC_1.0'
> > > > /srv/storage/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/9.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: /srv/storage/autobuild/run/instance-0/output-1/host/sparc-buildroot-linux-uclibc/sysroot/lib/libatomic.so.1: error adding symbols: DSO missing from command line
> > >
> > > There's something that puzzles me, maybe you can enlighten me.
> > >
> > > libcamera uses atomic operations internally, which, one some platforms,
> > > require linking against libatomic. As a result, we add libatomic to
> > > libcamera_deps (as an optional depedency), so libcamera.so is linked
> > > against libatomic.so. So far, so good. Why do we need applications that
> > > link against libcamera to also link against libatomic, if they don't use
> > > atomic operations directly themselves ?
> >
> > I would say that this is mandatory when building statically but static
> > build is disabled with libcamera on buildroot due to gnutls.
>
> Good point. How is this typically handled ? Are executable that use
> static linking required to know all the dependencies of all the
> libraries they use ?
Yes, when building statically, an executable must retrieve the full
list of dependencies and link with them in the correct order.
>From my point of view, the most appropriate way to handle those
dependencies is through pkg-config.
But again, libcamera has a mandatory dependency on gnutls which does
not support static linking
(https://gitlab.com/gnutls/gnutls/-/issues/203) so this is not an
issue.
>
> > It seems that __atomic_fetch_add_4 is used by main_window.cpp., here
> > is the result of grep:
> >
> > grep -r __atomic_fetch_add_4
> > output/build/libcamera-3a1f67a8031ac5ad96a11d5dc8b2e8976290497b/
> > grep: output/build/libcamera-3a1f67a8031ac5ad96a11d5dc8b2e8976290497b/build/src/qcam/qcam.p/main_window.cpp.o:
> > binary file matches
> > grep: output/build/libcamera-3a1f67a8031ac5ad96a11d5dc8b2e8976290497b/build/src/libcamera/libcamera.so:
> > binary file matches
> > grep: output/build/libcamera-3a1f67a8031ac5ad96a11d5dc8b2e8976290497b/build/src/libcamera/libcamera.so.p/message.cpp.o:
> > binary file matches
> >
> > atomic is probably pulled in because of std::shared_ptr which is used
> > by qcam since its addition in commit
> > 97e8b3a2eb321884fe1e15fb584f41a38cc33d51:
> > https://en.cppreference.com/w/cpp/memory/shared_ptr.
> > So I would suggest to just add libatomic dependency to qcam.
>
> Sounds good to me. Would you like to submit a patch, or should I ?
I'll send it in a few minutes.
Thanks for spotting my mistake in the first iteration.
>
> > > > Fixes:
> > > >  - http://autobuild.buildroot.org/results/d0726b2253f1f3d006e057f3b32c646c4b9b5f7a
> > > >
> > > > Signed-off-by: Fabrice Fontaine <fontaine.fabrice at gmail.com>
> > > > ---
> > > >  src/libcamera/meson.build | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> > > > index cc2b8669..af3533ad 100644
> > > > --- a/src/libcamera/meson.build
> > > > +++ b/src/libcamera/meson.build
> > > > @@ -160,6 +160,7 @@ libcamera_dep = declare_dependency(sources : [
> > > >                                         libcamera_public_headers,
> > > >                                     ],
> > > >                                     include_directories : libcamera_includes,
> > > > +                                   dependencies : libcamera_deps,
> > > >                                     link_with : libcamera)
> > > >
> > > >  subdir('proxy/worker')
>
> --
> Regards,
>
> Laurent Pinchart
Best Regards,

Fabrice


More information about the libcamera-devel mailing list