meson: drop libdl, threads, and librt dependencies

Our baseline glibc is 2.34, which merged libdl, libpthread (the
dependency('threads') target), and librt into libc. Empty .so/.a stubs
remain for backward compatibility with old binaries, but new builds
resolve dl_*, pthread_*, mq_*, timer_*, etc. directly from libc.
On musl the same libraries are likewise empty stubs.

Drop the libdl, threads, and librt entries from every meson.build, and
remove the now-stale 'Libs.private: -lrt -pthread' from libudev.pc.in
since both flags resolve to empty link-time stubs on glibc 2.34+ and
musl.

Verified with readelf -d that libsystemd.so, libudev.so, and systemd no
longer carry DT_NEEDED entries for libdl/libpthread/librt.
This commit is contained in:
Daan De Meyer
2026-05-18 21:17:38 +00:00
parent 5a1644de34
commit a14adac423
30 changed files with 15 additions and 130 deletions
+4 -20
View File
@@ -978,10 +978,7 @@ endif
#####################################################################
threads = dependency('threads')
librt = cc.find_library('rt')
libm = cc.find_library('m')
libdl = cc.find_library('dl')
# Header presence check only — dgettext itself is resolved via dlopen_libintl() at runtime, so we never
# link against libintl. On glibc dgettext lives in libc; on musl gettext-dev provides libintl.h alongside
@@ -1758,9 +1755,7 @@ libsystemd = shared_library(
link_with : [libc_wrapper_static,
libbasic_static],
link_whole : [libsystemd_static],
dependencies : [librt,
threads,
userspace],
dependencies : [userspace],
link_depends : libsystemd_sym,
install : true,
install_tag: 'libsystemd',
@@ -1779,14 +1774,11 @@ if static_libsystemd != 'false'
install_tag: 'libsystemd',
install_dir : libdir,
pic : static_libsystemd_pic,
dependencies : [libdl,
libgcrypt_cflags,
dependencies : [libgcrypt_cflags,
liblz4_cflags,
libm,
librt,
libxz_cflags,
libzstd_cflags,
threads,
userspace],
c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
@@ -1804,8 +1796,7 @@ libudev = shared_library(
'-Wl,--version-script=' + libudev_sym_path],
link_with : [libsystemd_static],
link_whole : libudev_basic,
dependencies : [threads,
userspace],
dependencies : [userspace],
link_depends : libudev_sym,
install : true,
install_tag: 'libudev',
@@ -1922,10 +1913,6 @@ nss_template = {
libshared_static,
libbasic_static,
],
'dependencies' : [
librt,
threads,
],
'install' : true,
'install_tag' : 'nss',
'install_dir' : libdir,
@@ -1938,10 +1925,7 @@ pam_template = {
libsystemd_static,
libshared_static,
],
'dependencies' : [
libpam_cflags,
threads,
],
'dependencies' : libpam_cflags,
'install' : true,
'install_tag' : 'pam',
'install_dir' : pamlibdir,