libunwind: check if libatomic is needed at configure time

Backport a patch submitted upstream to conditionally link explicitly to
libatomic, so we don't need to that in the recipe.

(From OE-Core rev: 797e645dbcb8a05a2514afc2d5bc2b0b661a0d0e)

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ross Burton 2025-04-25 12:43:20 +01:00 committed by Richard Purdie
parent f2dc1e086c
commit bb3fc52010
2 changed files with 39 additions and 1 deletions

View File

@ -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__

View 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://0003-Fixed-miscompilation-of-unw_getcontext-on-ARM.patch \
file://0004-Rework-inline-aarch64-as-for-setcontext.patch \ file://0004-Rework-inline-aarch64-as-for-setcontext.patch \
file://0005-Handle-musl-on-PPC32.patch \ file://0005-Handle-musl-on-PPC32.patch \
file://libatomic.patch \
" "
SRC_URI[sha256sum] = "ddf0e32dd5fafe5283198d37e4bf9decf7ba1770b6e7e006c33e6df79e6a6157" SRC_URI[sha256sum] = "ddf0e32dd5fafe5283198d37e4bf9decf7ba1770b6e7e006c33e6df79e6a6157"
@ -33,7 +34,6 @@ ARM_INSTRUCTION_SET:armv4 = "arm"
ARM_INSTRUCTION_SET:armv5 = "arm" ARM_INSTRUCTION_SET:armv5 = "arm"
LDFLAGS += "-Wl,-z,relro,-z,now" LDFLAGS += "-Wl,-z,relro,-z,now"
LDFLAGS:append:powerpc:libc-musl = " -latomic"
SECURITY_LDFLAGS:append:libc-musl = " -lssp_nonshared" SECURITY_LDFLAGS:append:libc-musl = " -lssp_nonshared"
CACHED_CONFIGUREVARS:append:libc-musl = " LDFLAGS='${LDFLAGS} -lucontext'" CACHED_CONFIGUREVARS:append:libc-musl = " LDFLAGS='${LDFLAGS} -lucontext'"