FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Load libselinux with dlopen instead of linking, and couple of fixes for 'sort' dlopen by bluca · Pull Request #317 · coreutils/coreutils · GitHub

Load libselinux with dlopen instead of linking, and couple of fixes for 'sort' dlopen - #317

Open
bluca wants to merge 3 commits into
coreutils:masterfrom
bluca:selinux_dlopen
Open

Load libselinux with dlopen instead of linking, and couple of fixes for 'sort' dlopen#317
bluca wants to merge 3 commits into
coreutils:masterfrom
bluca:selinux_dlopen

Conversation

bluca commented Jul 11, 2026

Copy link
Copy Markdown

libselinux is built in most distros, but it is seldomly needed at runtime (e.g.: it is not used by default on Debian/Ubuntu). In order to
allow building small images from the same packages, switch it to runtime optional by using dlopen(), and gracefully fallback if the
library is not found.

If libsystemd headers are available at build time stamp the ELF binaries using the ELF dlopen metadata format as defined by:
https://uapi-group.org/specifications/specs/elf_dlopen_metadata/
so that packaging tools for rpm/deb can automatically derive dependencies for it.

Also fix 'sort' dlopen when building with -O0.

I have already done the FSF copyright assignment paperwork some years back.

bluca added 3 commits July 11, 2026 01:06
libselinux is built in most distros, but it is seldomly needed at
runtime (e.g.: it is not used by default on Debian/Ubuntu). In order to
allow building small images from the same packages, switch it to
runtime optional by using dlopen(), and gracefully fallback if the
library is not found.

If libsystemd headers are available at build time stamp the ELF
binaries using the ELF dlopen metadata format as defined by:
https://uapi-group.org/specifications/specs/elf_dlopen_metadata/
so that packaging tools for rpm/deb can automatically derive
dependencies for it.
When building with -O0 md5_* helpers are unresolved, which pulls
gnulib’s external md5 implementation into the link, which in turn
calls OpenSSL directly and keeps -lcrypto around.

Ensure md5 wrappers remain local, so that when dlopen is used sort is
never linked against libcrypto.
If libsystemd headers are available at build time stamp the ELF
binaries using the ELF dlopen metadata format as defined by:
https://uapi-group.org/specifications/specs/elf_dlopen_metadata/
so that packaging tools for rpm/deb can automatically derive
dependencies for it.

pixelb commented Jul 11, 2026

Copy link
Copy Markdown
Member

Interesting.
Is there a common use case for building minimal images from standard packages? How would that compare to building custom packages with ./configure --without-selinux etc

Copy link
Copy Markdown
Member

Interesting. Is there a common use case for building minimal images from standard packages? How would that compare to building custom packages with ./configure --without-selinux etc

That seems a bit annoying with many different variants. E.g., SUSE already has coreutils, coreutils-single, and coreutils-systemd.

Unrelated to the commit, but I wonder why Gnulib doesn't define typeof in config.h so we can use that instead of __typeof__. Similar to how bool is defined by the bool module so programs can be written as if they had a decent C23 compiler. Maybe I will propose something on list.

bluca commented Jul 11, 2026

Copy link
Copy Markdown
Author

Interesting. Is there a common use case for building minimal images from standard packages? How would that compare to building custom packages with ./configure --without-selinux etc

Yeah especially for features that are useful only in specific circumstances like selinux, where unless the system uses selinux it doesn't provide anything. But it still lets us have a single package. For example in a build chroot selinux is really not needed, so the library and its deps can be skipped.

This is very important for central packages like coreutils, as it reduces the amount the amount of deps pulled in by default.

bluca commented Jul 11, 2026

Copy link
Copy Markdown
Author

btw I see gnulib has some selinux code too, would you like this new module to be added there instead perhaps? Would that make sense, or is it better here?

pixelb commented Jul 11, 2026

Copy link
Copy Markdown
Member

btw I see gnulib has some selinux code too, would you like this new module to be added there instead perhaps? Would that make sense, or is it better here?

I'm not sure. Let's work on this in coreutils for now

collinfunk commented Jul 11, 2026
edited
Loading

Copy link
Copy Markdown
Member

I skimmed over the threads here [1] [2], and it sounds like an interesting idea to me. Have any other programs other than systemd itself started moving to dlopen with these notes?

[1] https://mastodon.social/@pid_eins/112256363180973672
[2] https://mastodon.social/@pid_eins/115575195119541143

bluca commented Jul 11, 2026

Copy link
Copy Markdown
Author

I know of at least 3: libsdl3, mimic, openal-soft, as these are using the same dlopen metadata spec. I have a PR open against util-linux to make libselinux dlopened in the same way as this one.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL