bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 0/2] On ldconfig and ld.so.cache


From: Sergey Bugaev
Subject: [RFC PATCH 0/2] On ldconfig and ld.so.cache
Date: Wed, 17 May 2023 21:54:20 +0300

Hello,

having set up a very basic x86_64-gnu system to debug startup issues, I
was surprised to discover that my self-built ld.so does not look for the
shared libraries in /lib/x86_64-gnu/ (which is where Samuel Thibault's deb
packages place them) at all. I then learned that ld.so.cache and ldconfig
and ld.so.conf support is explicitly getting compiled out in the *-gnu
configurations -- and that this is being done intentionally, since
ldconfig is apparently considered to be a hack and a misfeature [0].

[0]: https://lists.debian.org/debian-hurd/2001/04/msg00179.html

(Might this be just due to misunderstanding of what ldconfig does? It's
not only about creating symlinks, it's primarily about the ld.so.cache and
ld.so.conf...)

<rant>

This doesn't really make sense to me: surely whether ld.so.cache is a
good idea or not is not tied to a particular kernel? Surely the kernel
could not care less about things like the file dystem layout and how
ld.so looks for shared libraries? Predicating ld.so.cache usage on whether
the GNU system is running on the Linux or Hurd kernel sounds like creating
pointless differences to me.

Moreover, Debian GNU/Hurd, the primary Hurd-based distribution, has been
shipping ld.so.cache on Hurd as a downstream patch [1] (note that more
changes would be required for x86_64-gnu because of FLAG_X8664_LIB64).
They don't really have a choice, it seems: with their "multiarch"
filesystem layout, the shared libraries are to be located in
/lib/i386-gnu/, but that is not a path that ld.so searches for libraries
in! This is solved by use_ldconfig=yes, and putting /lib/i386-gnu/ into
/etc/ld.so.conf.d/i386-gnu.conf, where it is then picked up by ldconfig,
which finds all the libraries and bakes their paths into the cache, where
ld.so then picks them up.

[1]: 
https://salsa.debian.org/glibc-team/glibc/-/raw/sid/debian/patches/hurd-i386/local-enable-ldconfig.diff

This is also another thing that suprises me: how come ldconfig does read
ld.so.conf, but ld.so does not? It's not an "ldconfig.conf" after all...
How is one even supposed to configure library paths with use_ldconfig=no?

</rant>

Anyway, maybe there are valid technical reasons to not enable ldconfig by
default; this is not a hill that I'm willing to die on. But wouldn't it be
nicer if it was easier to enable ldconfig downstream if desired? To that
end, I tweaked ldconfig.c to not use PATH_MAX (sadly, there are still
PATH_MAX usages in other places, e.g. chroot_canon.c), and moved a couple
of files to stop being specific to the Linux port. I hope that both of
these changes are uncontroversial. With these changes it is possible to
just patch in use_ldconfig=yes downstream (is desired, of course) and get
an ld.so.cache-enabled glibc on both i386-gnu and x86_64-gnu.

Sergey



reply via email to

[Prev in Thread] Current Thread [Next in Thread]