{"id":42,"date":"2022-06-21T21:26:27","date_gmt":"2022-06-21T21:26:27","guid":{"rendered":"https:\/\/blogs.gentoo.org\/gsoc\/?p=42"},"modified":"2022-07-08T14:52:30","modified_gmt":"2022-07-08T14:52:30","slug":"gentoo-musl-support-expansion-for-qt-kde-week-1","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/gsoc\/2022\/06\/21\/gentoo-musl-support-expansion-for-qt-kde-week-1\/","title":{"rendered":"Gentoo musl Support Expansion for Qt\/KDE Week 1"},"content":{"rendered":"<h1>Gentoo musl Support Expansion for Qt\/KDE Week 1<\/h1>\n<p>Hello!<\/p>\n<p>In the first week of Summer of Code I&#8217;ve spent my time fixing some dependencies of the Plasma desktop, as well as having learnt a lot regarding tooling and workflow.<\/p>\n<p>What I&#8217;ve accomplished this week is getting the Plasma desktop running, both with X11 and Wayland. For now it&#8217;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&#8217;ve fixed flatpak-builder so that they can be run inside a Flatpak. I do consider Flatpak a workaround and I&#8217;ll definitely focus on getting applications ported to run natively on musl later during this project.<\/p>\n<p>This far all of my patches has been patching build-time errors because they are easier to spot and fix, and I&#8217;ve been putting off the run-time bugs for later.<\/p>\n<p>&nbsp;<\/p>\n<p><!--more--><\/p>\n<p>I started off with patching dev-util\/flatpak-builder (https:\/\/github.com\/gentoo\/gentoo\/commit\/43e759c25a8e2960d3dff78c6696cb257ebaa39). This was done before the project started but I&#8217;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.<\/p>\n<h2>sys-fs\/lvm2 [<a href=\"https:\/\/github.com\/gentoo\/gentoo\/commit\/515ec4557c56cf0e82b95873056c40d8c6269694\">commit<\/a>]<\/h2>\n<p>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 <a href=\"https:\/\/www.gnu.org\/software\/libc\/manual\/html_node\/Standard-Streams.html\">modifiable in glibc<\/a>. As this was a bug that will probably pop up more I added it to <a href=\"https:\/\/wiki.gentoo.org\/wiki\/User:Sam\/Musl_porting_notes#error:_assignment_of_read-only_variable_.27.5Bstdout.7Cstdin.7Cstderr.5D.27\">Sam&#8217;s musl porting guide<\/a>! This has not been upstreamed yet. Spoilers: I also fixed a runtime issue caused by the exact same thing in week 2.<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<h2>sys-apps\/accountsservice [<a href=\"https:\/\/github.com\/gentoo\/gentoo\/pull\/25885\/commits\/69245ff691883260068cf206674228aff64cacd3\">commit<\/a>]<\/h2>\n<p>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&#8217;t defined in musl, it&#8217;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&#8217;ll do it in the following weeks. For now a simple conditional define for <a href=\"https:\/\/github.com\/gentoo\/gentoo\/pull\/25885\/commits\/69245ff691883260068cf206674228aff64cacd3#diff-a0d08afb54698d7e51c110f367cbcf603c12e6d8933fdf79621f799f24792585\">fgetspent_r was added<\/a>, this patch came from Alpine Linux. A rewrite is needed before upstreaming.<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<h2>sys-apps\/fakeroot-ng [upstream, link N\/A]<\/h2>\n<p>I also patched fakeroot-ng. This package failed to build because <span class=\"blob-code-inner blob-code-marker js-code-nav-pass \" data-code-marker=\"+\"><span class=\"pl-md\">__ptrace_request<\/span><\/span> wasn&#8217;t defined in musl. The patch for this was just to conditionally typedef it as int.<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<h2>media-libs\/freeimage [<a href=\"https:\/\/github.com\/gentoo\/gentoo\/commit\/a6bf07acc01f5848f2b0b7c17b93e05611a651b5\">commit<\/a>]<\/h2>\n<p>https:\/\/git.musl-libc.org\/cgit\/musl\/commit?id=98e688a9da5e7b2925dda17a2d6820dddf1fb28<\/p>\n<p>Freeimage was, similarly to accountsservice, a package where musl found badly written code.<\/p>\n<p><code>static BOOL DLL_CALLCONV<br \/>\nSave(FreeImageIO *io, FIBITMAP *dib, fi_handle handle, int page, int flags, void *data) {<br \/>\nif(!handle) {<br \/>\nreturn NULL;<br \/>\n}<br \/>\n...<\/code><\/p>\n<p>Here the return type is BOOL, which is defined as an integer. But in <a href=\"https:\/\/git.musl-libc.org\/cgit\/musl\/commit?id=98e688a9da5e7b2925dda17a2d6820dddf1fb28\">newer versions of musl<\/a> 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.<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p>Things that I spotted from my first week that I&#8217;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.<\/p>\n<p>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.<\/p>\n<p>For the &#8220;learning part&#8221;:<br \/>\n* I&#8217;ve learnt to submit patches both with pull requests and mailing lists.<br \/>\n* 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).<br \/>\n* How to format and what info to include in patches, for example GLEP 66.<br \/>\n* Using Emacs magit for working with git, ex. squashing commits.<\/p>\n<p>I&#8217;ve been working with sam, listout and leio this week. Thanks for all the help, nitpicking, and tips!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gentoo musl Support Expansion for Qt\/KDE Week 1 Hello! In the first week of Summer of Code I&#8217;ve spent my time fixing some dependencies of the Plasma desktop, as well as having learnt a lot regarding tooling and workflow. What &hellip; <a href=\"https:\/\/blogs.gentoo.org\/gsoc\/2022\/06\/21\/gentoo-musl-support-expansion-for-qt-kde-week-1\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":177,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts\/42"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/users\/177"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/comments?post=42"}],"version-history":[{"count":3,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts\/42\/revisions"}],"predecessor-version":[{"id":66,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/posts\/42\/revisions\/66"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/media?parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/categories?post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/gsoc\/wp-json\/wp\/v2\/tags?post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}