From 8b9d9541261a8d81d17d28515cce88cb315d4779 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 21 Oct 2026 07:44:29 -0700 Subject: [PATCH] fio: Link with libatomic when 64-bit atomics need it fio uses 64-bit C11 atomics, which riscv32 lowers to __atomic_load_8/__atomic_store_8 libcalls, so linking fio fails: ld.lld: error: undefined symbol: __atomic_load_8 ld.lld: error: undefined symbol: __atomic_store_8 Add a patch that makes configure check whether 64-bit atomics need libatomic and add it to LIBS only in that case. AI-Generated: Uses Claude Code Signed-off-by: Khem Raj --- ...ith-libatomic-when-64-bit-atomics-ne.patch | 56 +++++++++++++++++++ meta-oe/recipes-benchmark/fio/fio_3.43.bb | 1 + 2 files changed, 57 insertions(+) create mode 100644 meta-oe/recipes-benchmark/fio/fio/0001-configure-Link-with-libatomic-when-64-bit-atomics-ne.patch diff --git a/meta-oe/recipes-benchmark/fio/fio/0001-configure-Link-with-libatomic-when-64-bit-atomics-ne.patch b/meta-oe/recipes-benchmark/fio/fio/0001-configure-Link-with-libatomic-when-64-bit-atomics-ne.patch new file mode 100644 index 0000000000..7f6c115ae0 --- /dev/null +++ b/meta-oe/recipes-benchmark/fio/fio/0001-configure-Link-with-libatomic-when-64-bit-atomics-ne.patch @@ -0,0 +1,56 @@ +From: Khem Raj +Date: Wed, 21 Oct 2026 00:10:00 -0700 +Subject: [PATCH] configure: Link with libatomic when 64-bit atomics need it + +fio uses 64-bit C11 atomics, e.g. atomic_load_acquire() and +atomic_store_release() on the uint64_t inflight_issued and +inflight_numberio fields. On 32-bit targets without native 64-bit +atomic instructions, such as riscv32, the compiler lowers these to +__atomic_load_8/__atomic_store_8 libcalls, and linking fio fails: + + ld.lld: error: undefined symbol: __atomic_load_8 + ld.lld: error: undefined symbol: __atomic_store_8 + +Check whether a 64-bit atomic load/store links on its own, and if not, +whether it links with -latomic, and add libatomic to LIBS only in that +case. The test variable is global and the stored value depends on argc, +so the compiler cannot optimize the atomic operations away. + +Upstream-Status: Submitted [https://github.com/axboe/fio/pull/2163] +Signed-off-by: Khem Raj +--- + configure | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +--- a/configure ++++ b/configure +@@ -667,6 +667,29 @@ + fatal "C11 atomics support not found" + fi + ++########################################## ++# check if 64-bit atomics need libatomic ++# The variable is global and the stored value depends on argc so that the ++# compiler cannot optimize the atomic operations away. ++cat > $TMPC < ++#include ++_Atomic uint64_t v; ++int main(int argc, char **argv) ++{ ++ atomic_store_explicit(&v, (uint64_t)argc, memory_order_release); ++ return (int)atomic_load_explicit(&v, memory_order_acquire); ++} ++EOF ++libatomic="no" ++if ! compile_prog "" "" "64-bit atomics"; then ++ if compile_prog "" "-latomic" "64-bit atomics with libatomic"; then ++ libatomic="yes" ++ LIBS="-latomic $LIBS" ++ fi ++fi ++print_config "libatomic for 64-bit atomics" "$libatomic" ++ + + ########################################## + # check for wordsize diff --git a/meta-oe/recipes-benchmark/fio/fio_3.43.bb b/meta-oe/recipes-benchmark/fio/fio_3.43.bb index 928b31ff3d..e6445c2bfb 100644 --- a/meta-oe/recipes-benchmark/fio/fio_3.43.bb +++ b/meta-oe/recipes-benchmark/fio/fio_3.43.bb @@ -24,6 +24,7 @@ PACKAGECONFIG[numa] = ",--disable-numa,numactl" SRC_URI = " \ git://git.kernel.dk/fio.git;branch=master;tag=${BP} \ + file://0001-configure-Link-with-libatomic-when-64-bit-atomics-ne.patch \ " SRCREV = "d2dcd7e053d1902d2420f151c83990e6acdd9f8c"