Re: [PATCH] readutmp: load libsystemd with dlopen instead of linking

Pádraig Brady <[email protected]> Mon, 13 Jul 2026 21:05:17 +0100
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <[email protected]>
On 13/07/2026 20:09, Collin Funk wrote:
> Luca Boccassi <[email protected]> writes:
> 
>>>> So the main point of the proposed change is to improve diagnostics,
>>>> right?
>>>
>>> No. The point is to make it possible to install the coreutils package
>>> without installing the libselinux1 package. There are only two
>>> available options for that purpose: delete all the selinux-related
>>> code and remove the dependency entirely, or make it runtime-optional
>>> like openssl already is.
>>
>> Sorry, brainfart: substitute "systemd" for "selinux". Working to
>> change util-linux to dlopen libselinux and wires got crossed.
> 
> And the coreutils one [1].
> 
> I think the most obvious benefit is that you can avoid installing
> libselinux and libsystemd in a container where, as far as I am aware,
> they are not needed.
> 
> One other thing that occurred to me is that it might improve the
> performance of the single binary. That is, when running a command like
> 'true', you are no longer loading libselinux and libpcre2. That would be
> helpful for Red Hat containers, which use coreutils-single, and likely
> others:
> 
>      $ podman run --rm -it redhat/ubi10
>      $ ldd /usr/bin/coreutils
>      	  linux-vdso.so.1 (0x00007f06e92a7000)
>      	  libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f06e9110000)
>      	  libacl.so.1 => /lib64/libacl.so.1 (0x00007f06e9106000)
>      	  libattr.so.1 => /lib64/libattr.so.1 (0x00007f06e90fe000)
>      	  libcap.so.2 => /lib64/libcap.so.2 (0x00007f06e90f1000)
>      	  libc.so.6 => /lib64/libc.so.6 (0x00007f06e8f16000)
>      	  libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f06e8e74000)
>      	  /lib64/ld-linux-x86-64.so.2 (0x00007f06e92a9000)
> 
> Pádraig, I remember you looked into startup times fairly recently. Do
> you recall how much of that was from loading shared libraries? No
> problem if not, I can stop being lazy and test it myself.
> 
> Collin
> 
> [1] https://github.com/coreutils/coreutils/pull/317

shared library reduction is important for startup speed.
That's the main reason for the uutils slowdown IIRC,
as it's single binary and loads all shared libs for all commands.

I've not looked into the details but dlopen does seem potentially
useful for libselinux and it's ancillary functionality for many commands.
libsystemd seems more like core functionality for the commands that use it,
which is why I expressed some concern on dlopening that one.
Again I've not looked into the details on these.

cheers,
Padraig.