libfyaml: Detect the need for libatomic at configure time
PATCH 1/1 libfyaml: Detect the need for libatomic at configure time
Backport the upstream autoconf check which links a program using 8-byte atomics, first without and then with -latomic, and adds -latomic to the library link and libfyaml.pc when needed.
This replaces the TUNE_FEATURES match added in bea66b4bce, which had to enumerate the 32-bit tunes and could not tell whether the compiler can do the 8-byte operations inline. Clang does not link libatomic implicitly, so on mips, powerpc, riscv32 and i486 builds failed with:
error: undefined reference: __atomic_load_8
error: undefined reference: __atomic_compare_exchange_8
AI-Generated: Uses Claude Code
Signed-off-by Khem Raj <[email protected]>
--- ...e-platforms-need-latomic-for-atomics.patch | 95 +++++++++++++++++++ .../libfyaml/libfyaml_0.9.6.bb | 3 +- 2 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 meta/recipes-support/libfyaml/libfyaml/0003-autoconf-Some-platforms-need-latomic-for-atomics.patch
meta/recipes-support/libfyaml/libfyaml/0003-autoconf-Some-platforms-need-latomic-for-atomics.patch new file +95 -0
@@ -0,0 +1,95 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Pantelis Antoniou <[email protected]> +Date: Wed, 6 May 2026 10:51:13 +0300 +Subject: [PATCH] autoconf: Some platforms need -latomic for atomics + +Some (admittedly old) platforms require -latomic to support +8 byte atomics. So probe for it and then wire it all through +the build. + +Signed-off-by: Pantelis Antoniou <[email protected]> + +Upstream-Status: Backport [https://github.com/pantoniou/libfyaml/commit/fdfe2c054235ddbf83a2b235d08aba6316ae1ad1] +Signed-off-by: Khem Raj <[email protected]> +--- + configure.ac | 34 +++++++++++++++++++++++++++++++++- + libfyaml.pc.in | 2 +- + src/Makefile.am | 2 +- + 3 files changed, 35 insertions(+), 3 deletions(-) + +diff --git a/configure.ac b/configure.ac +index f5c854f..eb62f9c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -30,7 +30,7 @@ m4_pattern_allow([^(AM_EXTRA_RECURSIVE_TARGETS|AM_PROG_AR)$])dnl + # include them + m4_ifdef([AM_EXTRA_RECURSIVE_TARGETS], + [AM_EXTRA_RECURSIVE_TARGETS([doc-help doc-html doc-latexpdf doc-man doc-clean doc-markdown])], +- [AC_MSG_WARN([Old automake version without AM_EXTRA_RECURSIVE_TARGETS, doc-* rules won't be available at top level])]) ++ [AC_MSG_WARN([Old automake version without AM_EXTRA_RECURSIVE_TARGETS, doc-* rules will not be available at top level])]) + + m4_define(fyaml_major, `echo $VERSION | cut -d. -f1 | cut -d- -f1`) + m4_define(fyaml_minor, `echo $VERSION | cut -d. -f2 | cut -d- -f1`) +@@ -656,6 +656,38 @@ AC_SUBST(HAVE_HEAP_TRAMPOLINES) + AC_DEFINE_UNQUOTED([HAVE_HEAP_TRAMPOLINES], [$HAVE_HEAP_TRAMPOLINES], [Define to 1 if GCC heap trampolines are enabled]) + AM_CONDITIONAL([HAVE_HEAP_TRAMPOLINES], [ test x$HAVE_HEAP_TRAMPOLINES = x1 ]) + ++dnl check if -latomic is needed ++AC_CACHE_CHECK([whether 8-byte atomics need -latomic], ++ [ac_cv_libatomic_needed], ++ [ ++ save_LIBS="$LIBS" ++ ++ AC_LINK_IFELSE( ++ [AC_LANG_PROGRAM([[]], [[ ++ volatile unsigned long long v = 1; ++ return (int)__atomic_fetch_sub(&v, 1, __ATOMIC_SEQ_CST); ++ ]])], ++ [ac_cv_libatomic_needed=no], ++ [ ++ LIBS="$save_LIBS -latomic" ++ AC_LINK_IFELSE( ++ [AC_LANG_PROGRAM([[]], [[ ++ volatile unsigned long long v = 1; ++ return (int)__atomic_fetch_sub(&v, 1, __ATOMIC_SEQ_CST); ++ ]])], ++ [ac_cv_libatomic_needed=yes], ++ [ac_cv_libatomic_needed=unknown]) ++ ]) ++ ++ LIBS="$save_LIBS" ++ ]) ++ ++AS_IF([test "x$ac_cv_libatomic_needed" = "xyes"], [LIBS="$LIBS -latomic" ], ++ [test "x$ac_cv_libatomic_needed" = "xunknown"], ++ [ AC_MSG_ERROR([compiler supports __atomic builtins but linking 8-byte atomics failed, even with -latomic]) ]) ++AS_IF([test "x$ac_cv_libatomic_needed" = "xyes"], [ATOMIC_LIBS="-latomic"], [ ATOMIC_LIBS="" ]) ++AC_SUBST([ATOMIC_LIBS]) ++ + dnl trim cflags, cppflags, ldflags + CFLAGS=`echo $CFLAGS | sed -e 's/^[ ]*//'` + CPPFLAGS=`echo $CPPFLAGS | sed -e 's/^[ ]*//'` +diff --git a/libfyaml.pc.in b/libfyaml.pc.in +index 17278cc..9fce459 100644 +--- a/libfyaml.pc.in ++++ b/libfyaml.pc.in +@@ -6,5 +6,5 @@ includedir=@includedir@ + Name: libfyaml + Description: Fancy YAML 1.3 parser library + Version: @PACKAGE_VERSION@ +-Libs: -L${libdir} @ASAN_LIBS@ @PTHREAD_LIBS@ @LIBCLANG_LDFLAGS@ @LIBCLANG_LIBS@ @LIBM@ -lfyaml ++Libs: -L${libdir} @ASAN_LIBS@ @PTHREAD_LIBS@ @LIBCLANG_LDFLAGS@ @LIBCLANG_LIBS@ @LIBM@ @ATOMIC_LIBS@ -lfyaml + Cflags: -I${includedir} @ASAN_CFLAGS@ @PTHREAD_CFLAGS@ +diff --git a/src/Makefile.am b/src/Makefile.am +index 7d0aab5..1aa24b5 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -74,7 +74,7 @@ libfyaml_la_CPPFLAGS = $(AM_CPPFLAGS) $(INTERNAL_INCLUDES) + libfyaml_la_CFLAGS = $(AM_CFLAGS) + libfyaml_la_LDFLAGS = -no-undefined $(AM_LDFLAGS) $(AM_LIBLDFLAGS) \ + -version $(LIBTOOL_VERSION) +-libfyaml_la_LIBADD = $(LIBM) ++libfyaml_la_LIBADD = $(LIBM) $(ATOMIC_LIBS) + + # blake3 section + libfyaml_la_CPPFLAGS += -I$(top_srcdir)/src/blake3
meta/recipes-support/libfyaml/libfyaml_0.9.6.bb +1 -2
@@ -9,11 +9,10 @@ SRC_URI = "${GITHUB_BASE_URI}/download/v${PV}/libfyaml-${PV}.tar.gz \ file://0001-Fix-32-bit-build-by-removing-stray-parameter-to-fy_s.patch \ file://0002-vlsize-Handle-decoding-when-size_t-sizeof-uint64_t.patch \ file://0001-build-don-t-output-none-required-to-LIBM-if-no-linke.patch \ + file://0003-autoconf-Some-platforms-need-latomic-for-atomics.patch \ " SRC_URI[sha256sum] = "a59cc3331e2eb903ec36933ad52a45888041cac31e44f553a00511131242c483" inherit autotools pkgconfig github-releases -# Specify linking with -latomic on architectures missing 64bit atomics. -LDFLAGS += "${@bb.utils.contains_any('TUNE_FEATURES', '32 armv5 o32 m32', '-latomic', '', d)}" BBCLASSEXTEND = "native"