diff --git a/package/libusb/0001-configure.ac-link-with-latomic-if-needed.patch b/package/libusb/0001-configure.ac-link-with-latomic-if-needed.patch new file mode 100644 index 0000000000..5f6c88e57d --- /dev/null +++ b/package/libusb/0001-configure.ac-link-with-latomic-if-needed.patch @@ -0,0 +1,39 @@ +From 0b857081d687f7ee41483a3d7e9846af44a5ba7d Mon Sep 17 00:00:00 2001 +From: Fabrice Fontaine +Date: Mon, 7 Feb 2022 11:55:54 +0100 +Subject: [PATCH] configure.ac: link with -latomic if needed + +libusb unconditionally uses atomic_fetch_add since version 1.0.25 and +https://github.com/libusb/libusb/commit/1a08aa84d96397a3840a75abe66051f5360c2c84 +https://github.com/libusb/libusb/commit/eed8a371ea53939096ba94d44001e0637d042572 +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 + +Fixes: + - http://autobuild.buildroot.org/results/4a27a769bb3cdf78643c3049b87d792178d6512c + +Signed-off-by: Fabrice Fontaine +[Upstream status: https://github.com/libusb/libusb/pull/1064] +--- + configure.ac | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/configure.ac b/configure.ac +index f6cf2f9..002bcf6 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -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 +-- +2.34.1 + diff --git a/package/libusb/libusb.mk b/package/libusb/libusb.mk index 1e82cb9a85..aa306e295d 100644 --- a/package/libusb/libusb.mk +++ b/package/libusb/libusb.mk @@ -13,6 +13,8 @@ LIBUSB_LICENSE_FILES = COPYING LIBUSB_CPE_ID_VENDOR = libusb LIBUSB_DEPENDENCIES = host-pkgconf LIBUSB_INSTALL_STAGING = YES +# We're patching configure.ac +LIBUSB_AUTORECONF = YES # Avoid the discovery of udev for the host variant HOST_LIBUSB_CONF_OPTS = --disable-udev