]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
libunwind: check if libatomic is needed at configure time
authorRoss Burton <ross.burton@arm.com>
Fri, 25 Apr 2025 11:43:20 +0000 (12:43 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 29 Apr 2025 08:54:15 +0000 (09:54 +0100)
Backport a patch submitted upstream to conditionally link explicitly to
libatomic, so we don't need to that in the recipe.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-support/libunwind/libunwind/libatomic.patch [new file with mode: 0644]
meta/recipes-support/libunwind/libunwind_1.8.1.bb

diff --git a/meta/recipes-support/libunwind/libunwind/libatomic.patch b/meta/recipes-support/libunwind/libunwind/libatomic.patch
new file mode 100644 (file)
index 0000000..f39e92f
--- /dev/null
@@ -0,0 +1,38 @@
+From d6a0d8ce07c761e51b9dc7c5d16a9b06c3e93560 Mon Sep 17 00:00:00 2001
+From: Stephen Webb <swebb@blackberry.com>
+Date: Mon, 18 Mar 2024 10:22:26 -0400
+Subject: [PATCH] configure.ac: detect if -latomic is required
+
+Some OS runtimes require libatomic be linked in separately to get
+standard atomic operations to work. Try to detect that at configure
+time.
+
+Upstream-Status: Submitted [https://github.com/libunwind/libunwind/pull/732/]
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+---
+ configure.ac | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/configure.ac b/configure.ac
+index 758a27d19..d0ef5f3d9 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -94,6 +94,18 @@ dnl Checks for library functions.
+ AC_CHECK_FUNCS(dl_iterate_phdr dl_phdr_removals_counter dlmodinfo getunwind \
+               ttrace mincore pipe2 sigaltstack execvpe)
++AC_MSG_CHECKING([if -latomic is required])
++  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
++                        #include <stdatomic.h>
++                        atomic_bool ab_ = 0; atomic_llong al_ = 0;
++                    ]],[[
++                        atomic_load(&ab_); atomic_load(&al_);
++                    ]])],
++                 [use_libatomic=no],
++                 [use_libatomic=yes])
++AC_MSG_RESULT([$use_libatomic])
++AS_IF([test "$use_libatomic" = "yes"],[LIBS="-latomic $LIBS"])
++
+ AC_MSG_CHECKING([if building with AltiVec])
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ #ifndef __ALTIVEC__
index ee4a8401ba6779f3f08c9c35949453c2190881cb..b2c592b4350e1edf25a39d81a2811d06eabfe6c1 100644 (file)
@@ -13,6 +13,7 @@ SRC_URI = "${GITHUB_BASE_URI}/download/v${PV}/${BP}.tar.gz \
            file://0003-Fixed-miscompilation-of-unw_getcontext-on-ARM.patch \
            file://0004-Rework-inline-aarch64-as-for-setcontext.patch \
            file://0005-Handle-musl-on-PPC32.patch \
+           file://libatomic.patch \
            "
 
 SRC_URI[sha256sum] = "ddf0e32dd5fafe5283198d37e4bf9decf7ba1770b6e7e006c33e6df79e6a6157"
@@ -33,7 +34,6 @@ ARM_INSTRUCTION_SET:armv4 = "arm"
 ARM_INSTRUCTION_SET:armv5 = "arm"
 
 LDFLAGS += "-Wl,-z,relro,-z,now"
-LDFLAGS:append:powerpc:libc-musl = " -latomic"
 
 SECURITY_LDFLAGS:append:libc-musl = " -lssp_nonshared"
 CACHED_CONFIGUREVARS:append:libc-musl = " LDFLAGS='${LDFLAGS} -lucontext'"