From: Daan De Meyer Date: Wed, 13 May 2026 11:06:35 +0000 (+0200) Subject: libc,shared: detect newer library symbols at runtime via weak references (#42065) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=450853c72c3e925279d975cd75177898215f9918;p=thirdparty%2Fsystemd.git libc,shared: detect newer library symbols at runtime via weak references (#42065) For libc syscall wrappers (pidfd_open, fsopen, openat2, etc.) we previously gated the calls behind build-time HAVE_* checks. Replace these with weak external references, falling back to the raw syscall at runtime when the loaded glibc lacks the symbol. Drop the corresponding cc.has_function() loop from meson.build and disable -Wredundant-decls / readability-redundant-declaration for src/libc/ via meson c_args and a local .clang-tidy. For optional libraries (libcryptsetup, libdw, libarchive), drop the per-symbol HAVE_* checks. Always declare the prototypes, suppressing the redundant-decl warnings via DISABLE_WARNING_REDUNDANT_DECLS and NOLINT, and resolve the symbols after the main dlopen via a new DLSYM_OPTIONAL() helper that only assigns on success. libarchive's *_is_set wrappers now use fallback functions as their pointer initializers, so call sites never need to NULL-check. The same treatment applies to pidfd_spawn / posix_spawnattr_setcgroup_np in process-util.c and epoll_pwait2 in sd-event.c. coredump-config and coredump-submit get a dlopen_dw_has_dwfl_set_sysroot() helper. The kexec arch gate now uses defined(__NR_kexec_file_load) directly; pidfd.h uses __has_include_next() to decide whether to pull in glibc's header. This lets binaries built against newer glibc / libcryptsetup / libdw / libarchive headers still load and run on older targets where these symbols are absent. --- 450853c72c3e925279d975cd75177898215f9918