2
1
Эх сурвалжийг харах

package/iperf3: fix build with libatomic

Commit 9f94b3b354 "package/iperf3: bump to version 3.16" updated
the package but forgot to reflect a breaking change mentioned in
the release note [1], "iperf3 now requires pthreads and C atomic
variables to compile and run".

When the toolchain has no atomic support, or the libatomic is not
added in the linker flags, the compilation now fail with output:

    arm-buildroot-linux-gnueabi/bin/ld: ./.libs/libiperf.so: undefined reference to '__atomic_load_8'

This issue can be seen when running the iperf3 runtime test, with
command:

    support/testing/run-tests \
        -d dl -o output_test \
        tests.package.test_iperf3

This commit fixes the issue by adding a dependency on
BR2_TOOLCHAIN_HAS_ATOMIC and by adding an upstream patch to detect
if linking to libatomic is needed.

Fixes: [2]

[1] https://github.com/esnet/iperf/releases/tag/3.16
[2] https://gitlab.com/buildroot.org/buildroot/-/jobs/6466933622

Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
(cherry picked from commit f10488a4117e2ee544a602a5625cc5e897f18b2d)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Julien Olivain 1 жил өмнө
parent
commit
e36d6abb04

+ 42 - 0
package/iperf3/0001-Check-and-link-libatomic-if-needed.patch

@@ -0,0 +1,42 @@
+From bbf710e77e4a0438a2d995fd69b472e5ff054c69 Mon Sep 17 00:00:00 2001
+From: Jan Palus <jpalus@fastmail.com>
+Date: Sun, 3 Dec 2023 12:14:05 +0100
+Subject: [PATCH] Check and link libatomic if needed
+
+Some architectures without native support for 64-bit atomics need
+linking with libatomic.
+
+Signed-off-by: Julien Olivain <ju.o@free.fr>
+Upstream: https://github.com/esnet/iperf/commit/1511e9f85b548891ea53d4e378903344df1fd31e
+---
+ configure.ac | 14 +++++++++++++-
+ 1 file changed, 13 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 2594b39..ad7eaf1 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -92,7 +92,19 @@ CXX="$PTHREAD_CXX"
+ ])
+ 
+ # Atomics
+-AC_CHECK_HEADERS([stdatomic.h])
++AC_CHECK_HEADERS([stdatomic.h],
++    [AC_MSG_CHECKING([whether libatomic is required])
++    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdatomic.h>]], [[atomic_uint_fast64_t i; i++;]])],
++        [AC_MSG_RESULT([no])],
++        [save_LIBS="$LIBS"
++        LIBS="$LIBS -latomic"
++        AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdatomic.h>]], [[atomic_uint_fast64_t i; i++;]])],
++            [AC_MSG_RESULT([yes])],
++            [AC_MSG_ERROR([failed to find working configuration with atomics])]
++        )]
++    )],
++    []
++)
+ 
+ # Check for poll.h (it's in POSIX so everyone should have it?)
+ AC_CHECK_HEADERS([poll.h])
+-- 
+2.44.0
+

+ 2 - 0
package/iperf3/Config.in

@@ -1,5 +1,6 @@
 config BR2_PACKAGE_IPERF3
 	bool "iperf3"
+	depends on BR2_TOOLCHAIN_HAS_ATOMIC
 	depends on BR2_TOOLCHAIN_HAS_THREADS
 	help
 	  iperf is a tool for active measurements of the maximum
@@ -13,4 +14,5 @@ config BR2_PACKAGE_IPERF3
 	  http://software.es.net/iperf/index.html
 
 comment "iperf3 needs a toolchain w/ threads"
+	depends on BR2_TOOLCHAIN_HAS_ATOMIC
 	depends on !BR2_TOOLCHAIN_HAS_THREADS

+ 3 - 0
package/iperf3/iperf3.mk

@@ -11,6 +11,9 @@ IPERF3_LICENSE = BSD-3-Clause, BSD-2-Clause, MIT
 IPERF3_LICENSE_FILES = LICENSE
 IPERF3_CPE_ID_VENDOR = es
 
+# 0001-Check-and-link-libatomic-if-needed.patch
+IPERF3_AUTORECONF = YES
+
 IPERF3_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -D_GNU_SOURCE"
 
 ifeq ($(BR2_PACKAGE_OPENSSL),y)