[2/2] package/libv4l: link with libatomic when needed
diff mbox series

Message ID 20191030065303.22948-2-bernd.kuhls@t-online.de
State Rejected
Headers show
Series
  • [1/2] package/libv4l: fix musl build
Related show

Commit Message

Bernd Kuhls Oct. 30, 2019, 6:53 a.m. UTC
On some architectures, atomic operations are provided by the libatomic
library from gcc. Linking with libatomic is therefore necessary,
otherwise the build fails with:

/home/buildroot/autobuild/run/instance-1/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/7.4.0/../../../../sparc-buildroot-linux-uclibc/bin/ld:
 qv4l2-qv4l2.o: undefined reference to symbol '__atomic_fetch_add_4@@LIBATOMIC_1.0'

This is often for example the case on sparcv8 32 bit.

Fixes:
http://autobuild.buildroot.net/results/089/08952dbf89bf3c49da7697943441cee411940420/

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
---
 package/libv4l/libv4l.mk | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Thomas Petazzoni Oct. 30, 2019, 10:30 a.m. UTC | #1
On Wed, 30 Oct 2019 07:53:03 +0100
Bernd Kuhls <bernd.kuhls@t-online.de> wrote:

> On some architectures, atomic operations are provided by the libatomic
> library from gcc. Linking with libatomic is therefore necessary,
> otherwise the build fails with:
> 
> /home/buildroot/autobuild/run/instance-1/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/7.4.0/../../../../sparc-buildroot-linux-uclibc/bin/ld:
>  qv4l2-qv4l2.o: undefined reference to symbol '__atomic_fetch_add_4@@LIBATOMIC_1.0'
> 
> This is often for example the case on sparcv8 32 bit.
> 
> Fixes:
> http://autobuild.buildroot.net/results/089/08952dbf89bf3c49da7697943441cee411940420/

The LIBV4L_AUTORECONF = YES that was kept in
d0f3c9de49bfe3f8ac6e75a706540eefcc1afc07 was intended to fix this
libatomic linking issue, so I'm a bit confused.

Could you discuss this with Peter Seiderer (in Cc) ?

Thanks,

Thomas
Peter Seiderer Oct. 30, 2019, 10:26 p.m. UTC | #2
Hello *,

On Wed, 30 Oct 2019 11:30:40 +0100, Thomas Petazzoni <thomas.petazzoni@bootlin.com> wrote:

> On Wed, 30 Oct 2019 07:53:03 +0100
> Bernd Kuhls <bernd.kuhls@t-online.de> wrote:
>
> > On some architectures, atomic operations are provided by the libatomic
> > library from gcc. Linking with libatomic is therefore necessary,
> > otherwise the build fails with:
> >
> > /home/buildroot/autobuild/run/instance-1/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/7.4.0/../../../../sparc-buildroot-linux-uclibc/bin/ld:
> >  qv4l2-qv4l2.o: undefined reference to symbol '__atomic_fetch_add_4@@LIBATOMIC_1.0'
> >
> > This is often for example the case on sparcv8 32 bit.
> >
> > Fixes:
> > http://autobuild.buildroot.net/results/089/08952dbf89bf3c49da7697943441cee411940420/
>
> The LIBV4L_AUTORECONF = YES that was kept in
> d0f3c9de49bfe3f8ac6e75a706540eefcc1afc07 was intended to fix this
> libatomic linking issue, so I'm a bit confused.

Strange, this worked (when tested 3./4. October)..., now with buildroot master
I can reproduce the libatomic link failure even with the 'LIBV4L_AUTORECONF = YES'...

The working version link command (and output) was (and clearly using the *.la files):

/bin/sh ../../libtool  --tag=CXX   --mode=link /home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/sparc-linux-g++  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os   -std=c++11 -L/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib -lQt5Widgets -lQt5Gui -lQt5Core  -L/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib -lasound  -pthread  -o qv4l2 qv4l2-qv4l2.o qv4l2-general-tab.o qv4l2-ctrl-tab.o qv4l2-vbi-tab.o qv4l2-capture-win.o qv4l2-tpg-tab.o qv4l2-capture-win-qt.o qv4l2-capture-win-gl.o qv4l2-alsa_stream.o qv4l2-raw2sliced.o qv4l2-v4l2-tpg-core.o qv4l2-v4l2-tpg-colors.o qv4l2-moc_qv4l2.o qv4l2-moc_general-tab.o qv4l2-moc_capture-win.o qv4l2-moc_vbi-tab.o qv4l2-qrc_qv4l2.o ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la ../libv4l2util/libv4l2util.la ../libmedia_dev/libmedia_dev.la -lar
 gp
libtool: warning: library '/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Widgets.la' was moved.
libtool: warning: library '/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Gui.la' was moved.
libtool: warning: library '/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Gui.la' was moved.
libtool: warning: library '/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Core.la' was moved.
libtool: warning: library '/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Core.la' was moved.
libtool: warning: library '/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Widgets.la' was moved.
libtool: warning: library '/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Gui.la' was moved.
libtool: warning: library '/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Gui.la' was moved.
libtool: warning: library '/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Core.la' was moved.
libtool: warning: library '/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Core.la' was moved.
libtool: link: /home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/sparc-linux-g++ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -std=c++11 -pthread -o qv4l2 qv4l2-qv4l2.o qv4l2-general-tab.o qv4l2-ctrl-tab.o qv4l2-vbi-tab.o qv4l2-capture-win.o qv4l2-tpg-tab.o qv4l2-capture-win-qt.o qv4l2-capture-win-gl.o qv4l2-alsa_stream.o qv4l2-raw2sliced.o qv4l2-v4l2-tpg-core.o qv4l2-v4l2-tpg-colors.o qv4l2-moc_qv4l2.o qv4l2-moc_general-tab.o qv4l2-moc_capture-win.o qv4l2-moc_vbi-tab.o qv4l2-qrc_qv4l2.o  -L/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib /home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Widgets.so /home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Gui.so /home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/.
 ./sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Core.so -latomic /home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libasound.so -ldl ../../lib/libv4l2/.libs/libv4l2.so -lpthread /home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/build/libv4l-1.18.0/lib/libv4lconvert/.libs/libv4lconvert.so ../../lib/libv4lconvert/.libs/libv4lconvert.so -lrt -lm /home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libjpeg.so ../libv4l2util/.libs/libv4l2util.a ../libmedia_dev/.libs/libmedia_dev.a -largp -pthread -Wl,-rpath -Wl,/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib -Wl,-rpath -Wl,/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib -Wl,-rpath -Wl,/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/build/libv4l-1.18.0/lib/libv
 4l2/.libs -Wl,-rpath -Wl,/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/build/libv4l-1.18.0/lib/libv4lconvert/.libs -Wl,-rpath -Wl,/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib -Wl,-rpath -Wl,/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib

The actual/failing link command looks like the following:

/bin/sh ../../libtool  --tag=CXX   --mode=link /home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/sparc-linux-g++  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os   -std=c++11 -lQt5Widgets -lQt5Gui -lQt5Core  -lasound  -pthread  -o qv4l2 qv4l2-qv4l2.o qv4l2-general-tab.o qv4l2-ctrl-tab.o qv4l2-vbi-tab.o qv4l2-capture-win.o qv4l2-tpg-tab.o qv4l2-capture-win-qt.o qv4l2-capture-win-gl.o qv4l2-alsa_stream.o qv4l2-raw2sliced.o qv4l2-v4l2-tpg-core.o qv4l2-v4l2-tpg-colors.o qv4l2-moc_qv4l2.o qv4l2-moc_general-tab.o qv4l2-moc_capture-win.o qv4l2-moc_vbi-tab.o qv4l2-qrc_qv4l2.o ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la ../libv4l2util/libv4l2util.la ../libmedia_dev/libmedia_dev.la -largp
libtool: link: /home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/sparc-linux-g++ -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -std=c++11 -pthread -o qv4l2 qv4l2-qv4l2.o qv4l2-general-tab.o qv4l2-ctrl-tab.o qv4l2-vbi-tab.o qv4l2-capture-win.o qv4l2-tpg-tab.o qv4l2-capture-win-qt.o qv4l2-capture-win-gl.o qv4l2-alsa_stream.o qv4l2-raw2sliced.o qv4l2-v4l2-tpg-core.o qv4l2-v4l2-tpg-colors.o qv4l2-moc_qv4l2.o qv4l2-moc_general-tab.o qv4l2-moc_capture-win.o qv4l2-moc_vbi-tab.o qv4l2-qrc_qv4l2.o  -lQt5Widgets -lQt5Gui -lQt5Core -lasound ../../lib/libv4l2/.libs/libv4l2.so -lpthread /home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/build/libv4l-1.18.0/lib/libv4lconvert/.libs/libv4lconvert.so ../../lib/libv4lconvert/.libs/libv4lconvert.so -lrt -lm -ljpeg ../libv4l2util/.libs/libv4l2util.a ../libmedia_dev/.libs/libmedia_dev.a -largp -pthread -Wl,-rpath -Wl,/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/build/libv4l-1.18.0/
 lib/libv4l2/.libs -Wl,-rpath -Wl,/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/build/libv4l-1.18.0/lib/libv4lconvert/.libs
/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/7.4.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: qv4l2-qv4l2.o: undefined reference to symbol '__atomic_fetch_add_4@@LIBATOMIC_1.0'
/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/7.4.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: /home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/sparc-buildroot-linux-uclibc/sysroot/lib/libatomic.so.1: error adding symbols: DSO missing from command line

And is not using the Qt5 *.la files (checked using strace)...

Adding the (missing?) '-L/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib'
libtool command line parameter fixes the linking for the actual build...

Any hint which (buildroot?) change triggered the remove of the link/library path removal?

Regards,
Peter

>
> Could you discuss this with Peter Seiderer (in Cc) ?
>
> Thanks,
>
> Thomas
Thomas Preston Nov. 20, 2019, 2:46 p.m. UTC | #3
Hey,

On 30/10/2019 22:26, Peter Seiderer wrote:
> Adding the (missing?) '-L/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib'
> libtool command line parameter fixes the linking for the actual build...
> 
> Any hint which (buildroot?) change triggered the remove of the link/library path removal?
> 

As previously discussed [0], the missing `-L..` is because pkgconf no longer
returns "system" include or library directories with -I and -L  (see [1]).
These are already in the compiler's default search path and were causing
include-order related bugs when using -isystem.

However, it looks like that change has caused a problem here, where the output
from pkgconf is being passed to libtool to point it at the "system" library
directory in the sysroot.

I don't know enough about libtool yet, but I think there are a few ways around
this:
1. Tell libtool where the sysroot is by some other mechanism
2. Tell pkgconf that we want to keep the system lib directories, when it is
   used to create arguments to libtool. The following argument will always 
   return -L, as expected above:

        pkg-config --keep-system-libs

I'm looking into this, but someone with a more intimate knowledge of libtool +
pkg-autotools.mk, might be able to help here.

Thanks,
Thomas Preston

[0] http://lists.busybox.net/pipermail/buildroot/2019-November/266369.html
[1] http://lists.busybox.net/pipermail/buildroot/2019-October/263178.html
Peter Seiderer Nov. 20, 2019, 7:44 p.m. UTC | #4
Hello *,

On Wed, 20 Nov 2019 14:46:03 +0000, Thomas Preston <thomas.preston@codethink.co.uk> wrote:

> Hey,
>
> On 30/10/2019 22:26, Peter Seiderer wrote:
> > Adding the (missing?) '-L/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib'
> > libtool command line parameter fixes the linking for the actual build...
> >
> > Any hint which (buildroot?) change triggered the remove of the link/library path removal?
> >
>
> As previously discussed [0], the missing `-L..` is because pkgconf no longer
> returns "system" include or library directories with -I and -L  (see [1]).
> These are already in the compiler's default search path and were causing
> include-order related bugs when using -isystem.
>
> However, it looks like that change has caused a problem here, where the output
> from pkgconf is being passed to libtool to point it at the "system" library
> directory in the sysroot.
>
> I don't know enough about libtool yet, but I think there are a few ways around
> this:
> 1. Tell libtool where the sysroot is by some other mechanism
> 2. Tell pkgconf that we want to keep the system lib directories, when it is
>    used to create arguments to libtool. The following argument will always
>    return -L, as expected above:
>
>         pkg-config --keep-system-libs

The libv4l/libatomic case can be fixed by the following (hack):

diff --git a/package/libv4l/libv4l.mk b/package/libv4l/libv4l.mk
index a3bf099221..46c1ab9a48 100644
--- a/package/libv4l/libv4l.mk
+++ b/package/libv4l/libv4l.mk
@@ -16,7 +16,7 @@ LIBV4L_AUTORECONF = YES
 LIBV4L_DEPENDENCIES += host-gettext

 # fix uclibc-ng configure/compile
-LIBV4L_CONF_ENV = ac_cv_prog_cc_c99='-std=gnu99'
+LIBV4L_CONF_ENV = ac_cv_prog_cc_c99='-std=gnu99' PKG_CONFIG_SYSROOT_DIR=$(STAGING_DIR)

 # v4l-utils components have different licences, see v4l-utils.spec for details
 LIBV4L_LICENSE = GPL-2.0+ (utilities), LGPL-2.1+ (libraries)

Regards,
Peter

>
> I'm looking into this, but someone with a more intimate knowledge of libtool +
> pkg-autotools.mk, might be able to help here.
>
> Thanks,
> Thomas Preston
>
> [0] http://lists.busybox.net/pipermail/buildroot/2019-November/266369.html
> [1] http://lists.busybox.net/pipermail/buildroot/2019-October/263178.html
>
Thomas Preston Nov. 21, 2019, 11:33 a.m. UTC | #5
On 20/11/2019 19:44, Peter Seiderer wrote:
> The libv4l/libatomic case can be fixed by the following (hack):
> 
> diff --git a/package/libv4l/libv4l.mk b/package/libv4l/libv4l.mk
> index a3bf099221..46c1ab9a48 100644
> --- a/package/libv4l/libv4l.mk
> +++ b/package/libv4l/libv4l.mk
> @@ -16,7 +16,7 @@ LIBV4L_AUTORECONF = YES
>  LIBV4L_DEPENDENCIES += host-gettext
> 
>  # fix uclibc-ng configure/compile
> -LIBV4L_CONF_ENV = ac_cv_prog_cc_c99='-std=gnu99'
> +LIBV4L_CONF_ENV = ac_cv_prog_cc_c99='-std=gnu99' PKG_CONFIG_SYSROOT_DIR=$(STAGING_DIR)
> 
>  # v4l-utils components have different licences, see v4l-utils.spec for details
>  LIBV4L_LICENSE = GPL-2.0+ (utilities), LGPL-2.1+ (libraries)
> 

`PKG_CONFIG_SYSROOT_DIR=$(STAGING_DIR)` should already be set when we
use the PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)". Which is set in
TARGET_CONFIGURE_ENV.

Presumably setting PKG_CONFIG_SYSROOT_DIR here causes the system-libs
`-L` flag to return, but I'm not sure why.

I'm building with the failing defconfig [0] to try and reproduce and
investigate this.

Thanks

[0] http://autobuild.buildroot.net/results/089/08952dbf89bf3c49da7697943441cee411940420/defconfig
Thomas Preston Nov. 21, 2019, 4:46 p.m. UTC | #6
On 20/11/2019 19:44, Peter Seiderer wrote:
> On Wed, 20 Nov 2019 14:46:03 +0000, Thomas Preston <thomas.preston@codethink.co.uk> wrote:
>> On 30/10/2019 22:26, Peter Seiderer wrote:
>>> Adding the (missing?) '-L/home/seiderer/Work/Buildroot/build_sparc_qt5multimedia_001/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib'
>>> libtool command line parameter fixes the linking for the actual build...
>>>
>>> Any hint which (buildroot?) change triggered the remove of the link/library path removal?
>>>
>>
>> As previously discussed [0], the missing `-L..` is because pkgconf no longer
>> returns "system" include or library directories with -I and -L  (see [1]).
>> These are already in the compiler's default search path and were causing
>> include-order related bugs when using -isystem.
>>
>> However, it looks like that change has caused a problem here, where the output
>> from pkgconf is being passed to libtool to point it at the "system" library
>> directory in the sysroot.
>>
>> I don't know enough about libtool yet, but I think there are a few ways around
>> this:
>> 1. Tell libtool where the sysroot is by some other mechanism
>> 2. Tell pkgconf that we want to keep the system lib directories, when it is
>>    used to create arguments to libtool. The following argument will always
>>    return -L, as expected above:
>>
>>         pkg-config --keep-system-libs
> 
> The libv4l/libatomic case can be fixed by the following (hack):
> 
> diff --git a/package/libv4l/libv4l.mk b/package/libv4l/libv4l.mk
> index a3bf099221..46c1ab9a48 100644
> --- a/package/libv4l/libv4l.mk
> +++ b/package/libv4l/libv4l.mk
> @@ -16,7 +16,7 @@ LIBV4L_AUTORECONF = YES
>  LIBV4L_DEPENDENCIES += host-gettext
> 
>  # fix uclibc-ng configure/compile
> -LIBV4L_CONF_ENV = ac_cv_prog_cc_c99='-std=gnu99'
> +LIBV4L_CONF_ENV = ac_cv_prog_cc_c99='-std=gnu99' PKG_CONFIG_SYSROOT_DIR=$(STAGING_DIR)
> 
>  # v4l-utils components have different licences, see v4l-utils.spec for details
>  LIBV4L_LICENSE = GPL-2.0+ (utilities), LGPL-2.1+ (libraries)
> 

This change works because the Buildroot's pkg-config wrapper script [0]
configures the following variables as relative to $(HOST_DIR)/bin:

	PKG_CONFIG_SYSROOT_DIR
	PKG_CONFIG_SYSTEM_INCLUDE_PATH
	PKG_CONFIG_SYSTEM_LIBRARY_PATH

So when you set PKG_CONFIG_SYSROOT_DIR=$(STAGING_DIR) (an absolute path),
pkgconf detects the difference and prints the sysroot system lib dirs.
These `-L` flags end up in the QT5_LIBS variable via autoconf.

	--- output/build/libv4l-1.18.0-broken/Makefile  2019-11-21 14:04:00.373262772 +0000
	+++ output/build/libv4l-1.18.0/Makefile 2019-11-21 15:53:40.388627694 +0000
	[snip]
	@@ -385,15 +385,15 @@
	[snip]
	-QT5_LIBS = -lQt5Widgets -lQt5Gui -lQt5Core
	+QT5_LIBS = -L/home/br-user/output/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib -lQt5Widgets -lQt5Gui -lQt5Core
	[snip]

Which in turn, tell libtool to search `.../sysroot/usr/lib` for the .la
files, which contain the appropriate `-latomic` flag:

	$ grep latomic output/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libQt5Widgets.la
	dependency_libs='-latomic  -lQt5Gui -lQt5Core -lpthread -lrt -lpthread -ldl'

The same effect can be achieved by telling pkgconf to keep the system 
libs:

	diff --git a/package/libv4l/libv4l.mk b/package/libv4l/libv4l.mk
	index a3bf099221..93edbfedd5 100644
	--- a/package/libv4l/libv4l.mk
	+++ b/package/libv4l/libv4l.mk
	@@ -16,7 +16,9 @@ LIBV4L_AUTORECONF = YES
	 LIBV4L_DEPENDENCIES += host-gettext

	 # fix uclibc-ng configure/compile
	-LIBV4L_CONF_ENV = ac_cv_prog_cc_c99='-std=gnu99'
	+LIBV4L_CONF_ENV = ac_cv_prog_cc_c99='-std=gnu99' PKG_CONFIG_ALLOW_SYSTEM_LIBS=1

	 # v4l-utils components have different licences, see v4l-utils.spec for details
	 LIBV4L_LICENSE = GPL-2.0+ (utilities), LGPL-2.1+ (libraries)

Which I think is the right solution when we use pkgconf to generate
flags for libtool.

Thoughts?
Thomas Preston

[0] https://git.buildroot.net/buildroot/tree/package/pkgconf/pkg-config.in

Patch
diff mbox series

diff --git a/package/libv4l/libv4l.mk b/package/libv4l/libv4l.mk
index a3bf099221..3c58f98391 100644
--- a/package/libv4l/libv4l.mk
+++ b/package/libv4l/libv4l.mk
@@ -84,6 +84,11 @@  ifeq ($(BR2_PACKAGE_SDL2_IMAGE),y)
 LIBV4L_DEPENDENCIES += sdl2_image
 endif
 
+# Uses __atomic_fetch_add_4
+ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
+LIBV4L_LIBS += -latomic
+endif
+
 LIBV4L_CONF_ENV += LIBS="$(LIBV4L_LIBS)"
 
 $(eval $(autotools-package))