configure.ac: link with -latomic if needed
authorFabrice Fontaine <fontaine.fabrice@gmail.com>
Mon, 7 Feb 2022 10:55:54 +0000 (11:55 +0100)
committerTormod Volden <debian.tormod@gmail.com>
Wed, 16 Mar 2022 16:53:00 +0000 (17:53 +0100)
libusb unconditionally uses atomic_fetch_add since version 1.0.25 and
commit 1a08aa8 and commit eed8a37 but some architectures (e.g. sparc)
needs to link with -latomic to be able to use it. So check if -latomic
is needed and update libusb-1.0.pc accordingly to avoid the following
build failure with openocd:

/home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/10.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: /home/buildroot/autobuild/instance-0/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libusb-1.0.so: undefined reference to `__atomic_fetch_add_4'
collect2: error: ld returned 1 exit status

Full build log:
http://autobuild.buildroot.org/results/4a27a769bb3cdf78643c3049b87d792178d6512c

Closes #1064

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
configure.ac
libusb/version_nano.h

index f6cf2f9..002bcf6 100644 (file)
@@ -152,6 +152,7 @@ if test "x$platform" = xposix; then
        AC_SEARCH_LIBS([pthread_create], [pthread],
                [test "x$ac_cv_search_pthread_create" != "xnone required" && AC_SUBST(THREAD_LIBS, [-lpthread])],
                [], [])
+       AC_SEARCH_LIBS([__atomic_fetch_add_4], [atomic])
 elif test "x$platform" = xwindows; then
        AC_DEFINE([PLATFORM_WINDOWS], [1], [Define to 1 if compiling for a Windows platform.])
 else
index 10c3ecf..2125a59 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11695
+#define LIBUSB_NANO 11696