From 41d0ff60d9343fda1bacc4749d5d34a2815546ad Mon Sep 17 00:00:00 2001 From: vasilito Date: Fri, 31 Jul 2026 15:04:40 +0300 Subject: [PATCH] libelf: new recipe (elfutils carve-out) for Mesa radeonsi; wire into mesa Mesa's radeonsi gallium driver requires libelf. Add a libelf recipe that builds only the elfutils lib/+libelf/ subdirs (avoiding the libdw/libasm/tools glibc surface) as a PIC static archive, relying on the new relibc headers/functions (byteswap/error/libintl/ar/search + tsearch/mempcpy/rawmemchr). Installs libelf.a + libelf.h/gelf.h/nlist.h + libelf.pc. Wired into mesa deps. Verified: cook libelf - successful. --- local/recipes/dev/libelf/recipe.toml | 77 ++++++++++++++++++++++++++++ local/recipes/libs/mesa/recipe.toml | 4 ++ recipes/dev/libelf | 1 + 3 files changed, 82 insertions(+) create mode 100644 local/recipes/dev/libelf/recipe.toml create mode 120000 recipes/dev/libelf diff --git a/local/recipes/dev/libelf/recipe.toml b/local/recipes/dev/libelf/recipe.toml new file mode 100644 index 0000000000..6fadeb9672 --- /dev/null +++ b/local/recipes/dev/libelf/recipe.toml @@ -0,0 +1,77 @@ +[package] +name = "libelf" +# libelf only, carved out of elfutils. Mesa's radeonsi (AMD) gallium driver +# requires libelf (dependency('libelf') / cc.find_library('elf')). We build just +# the elfutils libelf sublibrary (+ its lib/ helper) rather than all of elfutils +# (libdw/libasm/tools drag in a large glibc surface). Version tracks elfutils. +version = "0.190" +description = "libelf — ELF object file access library (from elfutils). Required by Mesa's radeonsi gallium driver." + +[source] +tar = "https://sourceware.org/elfutils/ftp/0.190/elfutils-0.190.tar.bz2" + +[build] +template = "custom" +# libelf's lib/ helper (eu-config.h/system.h) pulls libintl.h, error.h, +# byteswap.h — now provided by relibc — plus argp.h/obstack.h from the deps. +dependencies = [ + "zlib", + "argp-standalone", + "musl-obstack", + "musl-fts", +] +script = ''' +DYNAMIC_INIT + +# libelf links into radeonsi.so, so build a PIC static archive (baked in; no +# extra runtime .so to ship). -fPIC + static. elfutils compiles with -Werror +# and trips on -Wformat-nonliteral etc. under the Redox cross toolchain; drop +# -Werror (also via --disable-werror below) so warnings are non-fatal. +export CFLAGS="-fPIC -Wno-error ${CFLAGS:-}" + +# elfutils' configure autoconf checks assume a few glibc behaviours; force the +# results that are correct for relibc so configure completes without running +# target binaries. +COOKBOOK_CONFIGURE_FLAGS+=( + --enable-static + --disable-shared + --disable-werror + --disable-nls + --disable-debuginfod + --disable-libdebuginfod + --disable-demangler + --without-zstd + --without-bzlib + --without-lzma + ac_cv_func_mempcpy=yes +) + +# Configure (out-of-tree, in COOKBOOK_BUILD which is CWD), then build ONLY the +# lib/ helper and libelf/, skipping libdw/libasm/backends/src (not needed and +# glibc-heavy). +"${COOKBOOK_CONFIGURE}" "${COOKBOOK_CONFIGURE_FLAGS[@]}" +"${COOKBOOK_MAKE}" -C lib -j"${COOKBOOK_MAKE_JOBS}" +"${COOKBOOK_MAKE}" -C libelf -j"${COOKBOOK_MAKE_JOBS}" libelf.a + +# Install libelf.a + public headers by hand (the libelf `install` target also +# pulls the shared lib / versioning we skipped). +mkdir -p "${COOKBOOK_STAGE}/usr/lib" "${COOKBOOK_STAGE}/usr/include" "${COOKBOOK_STAGE}/usr/lib/pkgconfig" +cp libelf/libelf.a "${COOKBOOK_STAGE}/usr/lib/" +cp "${COOKBOOK_SOURCE}/libelf/libelf.h" "${COOKBOOK_SOURCE}/libelf/gelf.h" "${COOKBOOK_SOURCE}/libelf/nlist.h" "${COOKBOOK_STAGE}/usr/include/" + +# Provide a pkg-config so Mesa's dependency('libelf') resolves (its +# find_library('elf') fallback would also work, but the .pc is cheap). +cat > "${COOKBOOK_STAGE}/usr/lib/pkgconfig/libelf.pc" <