Gentoo musl Support Expansion for Qt/KDE Week 1

Gentoo musl Support Expansion for Qt/KDE Week 1


In the first week of Summer of Code I’ve spent my time fixing some dependencies of the Plasma desktop, as well as having learnt a lot regarding tooling and workflow.

What I’ve accomplished this week is getting the Plasma desktop running, both with X11 and Wayland. For now it’s just a bare bones desktop with Konsole (terminal) and Dolphin (file manager) running. To get most of my glibc applications running under musl I’ve fixed flatpak-builder so that they can be run inside a Flatpak. I do consider Flatpak a workaround and I’ll definitely focus on getting applications ported to run natively on musl later during this project.

This far all of my patches has been patching build-time errors because they are easier to spot and fix, and I’ve been putting off the run-time bugs for later.


I started off with patching dev-util/flatpak-builder ( This was done before the project started but I’ll still mention it here. The problem with this package was that it used the GNU macro TEMP_FAILURE_RETRY, and error() from error.h. Fixing this was just checking via the preprocessor if they were defined and if not, just define an identical replacement.

sys-fs/lvm2 [commit]

The second package was sys-fs/lvm2. The fix here was similar to flatpak-builder, ie it used GNU extensions not defined in musl. Specifically it had to do with the standard streams being const in musl, but modifiable in glibc. As this was a bug that will probably pop up more I added it to Sam’s musl porting guide! This has not been upstreamed yet. Spoilers: I also fixed a runtime issue caused by the exact same thing in week 2.


sys-apps/accountsservice [commit]

A more interesting patch was sys-apps/accountsservice. It uses fgetspent_r to enumerate the shadow file to find users. The problem here is not that fgetspent_r isn’t defined in musl, it’s that enumerating shadow to get a list of users is a wrong thing to do in the first place. To properly fix accountsservice a larger rewrite is needed. After a chat in #musl I got suggestions on how to do that and I’ll do it in the following weeks. For now a simple conditional define for fgetspent_r was added, this patch came from Alpine Linux. A rewrite is needed before upstreaming.


sys-apps/fakeroot-ng [upstream, link N/A]

I also patched fakeroot-ng. This package failed to build because __ptrace_request wasn’t defined in musl. The patch for this was just to conditionally typedef it as int.


media-libs/freeimage [commit]

Freeimage was, similarly to accountsservice, a package where musl found badly written code.

Save(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) {
if(!handle) {
return NULL;

Here the return type is BOOL, which is defined as an integer. But in newer versions of musl NULL is defined as nullptr. Because nullptr cannot implicitly convert to int this will break. In earlier versions of musl NULL was defined as 0 and this would work.


Things that I spotted from my first week that I’ll continue working on are lvm2 (_allocate_memory needs rewrite, removing is fine for now), Baloo (runtime bug), librsvg (weird cargo error) and rewriting accountsservice.

For me librsvg segfaults when built by an unprivileged user and then installed by root. This error is probably related to ld library path according to Sam.

For the “learning part”:
* I’ve learnt to submit patches both with pull requests and mailing lists.
* With listout getting stuck on librsvg I also learned how to compile Rust programs with debuginfo and how to use gdbserver, rust-gdb and GEF (sam: indeed, it is comfy).
* How to format and what info to include in patches, for example GLEP 66.
* Using Emacs magit for working with git, ex. squashing commits.

I’ve been working with sam, listout and leio this week. Thanks for all the help, nitpicking, and tips!

This entry was posted in musl KDE. Bookmark the permalink.

Leave a Reply

Your email address will not be published.