SkillAgentSearch skills...

Muslx32

muslx32 (musl libc and x32 abi) overlay for Gentoo Linux

Install / Use

/learn @orsonteodoro/Muslx32
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

muslx32

This is an unofficial muslx32 (musl libc and x32 ABI) overlay for Gentoo Linux

STATUS

  • Indefinite hold.

Gentoo removed the profile in 2019-06-12, so updates are on hold. Decision to update and maintain this profile on this overlay is uncertain, but maybe possible to restore back.

The last update before 2020 was in Jul 17, 2018.

As of Nov 2020, this repo is slowly being updated. It is not recommended to use it until the system dependencies (stage 1 to 3) are up to date because of security reasons. This means that all packages in sys-* category be updated first. Then, all packages in dev-* category will be updated. All userspace programs (@world set - @system set) that sit on top of those layers will be done afterwards.

Once the project is up to date, the status above will change to READY. If you are impatent or want to jump ahead, you may fork this repo (or work on a local repo) and bring all system ebuilds and toolchain up to date yourself. I recommend looking at both the musl overlay (https://github.com/gentoo/musl) and the Alpine Linux repo (https://git.alpinelinux.org/aports/tree/) for additional musl patches. Diff the ebuilds against the ones in the gentoo-overlay or the musl overlay to see what changes this repo has made to those ebuilds. Do the easy musl patching first, then do the more difficult x32 part next. Keep those parts in the ebuild self-contained and documented in a conditional as follows to easily migrate ebuild updates forward.

<pre> if [[ "${CHOST}" =~ "muslx32" ]] ; then ... fi </pre>

The ebuild / overlay precedence is low-to-high with gentoo -> musl -> muslx32 -> local, respectively. This means that test gentoo ebuilds first. If gentoo-overlay doesn't work or buggy, try the musl-overlay for a fix. If musl-overlay can't fix it, then use the muslx32 ebuilds. If the priority is done correctly, it should do it automatically.

About the muslx32 profile

This profile uses a 64-bit linux kernel with x32 ABI compatibility. Almost all of the userland libraries and programs are built as native x32 ABI. The profile contains patches that fix x32 problems and musl problems. Other overlays seperate them, but in this overlay we combine them.

Current goals

The current goal is trying to get popular packages and necessary developer tools working on the platform/profile for widespread adoption.

Currently Multilib GCC and multilib musl works but not all the time for some packages if x32 ABI is the default. This will allow for x32 as the default ABI but allow for the profile to run amd64 or x86 only programs, which is required for programs like wine, networkmanager, firefox, nodejs, and grub-install which upstream refuses to support x32 for some of these packages.

Why musl and x32 and Gentoo?

Musl because it is lightweight. x32 ABI because it reduces memory usage. Alpine Linux, an embedded mini distro, had Firefox tagging my USB for many tabs resulting in a big slow down. I was really disappointed about Alpine and the shortcomings of the other previously tested distros. It was many times slower than the RAM based distros such as Linux Mint and Slax, so there was a motivation to work on muslx32 for Gentoo. Tiny Linux and Slax packages were pretty much outdated. blueness said that he wouldn't make muslx32 as top priority or it wasn't his job to do or after the hardened GCC patches for the platform were ready, so I decided to just do it myself without the hardened part.

What is x32?

x32 ABI is 32-bit (4-bytes) per integer, long, pointer using all of the x86_64 general purpose registers identified as (rax,rbx,rcx,r11-r15,rsi,rdi) and using sse registers. Long-long integers are 8 bytes. C/C++ programs will use ILP32 preprocessor checks to distinguish between 32/64 bit systems. The build system may also compare sizeof(void*) to see if it has 4 bytes for 32-bit for 8 bytes and 64-bit for LP64 (longs are 8 bytes as well as pointers) and x86_64 defined.

Advantages of this platform

x32 ABI vs x86 ABI

x32 is better than x86 because the compiler can utilize the x86_64 calling convention by dumping arguments to the registers first before dumping additional arguments on the stack. The compiler can futher optimize the code by reducing the number of instructions executed and utilize the full register and 64 bit instructions.

x32 ABI vs x86_64 ABI

x32 is better than x86_64 because of reduced pointer size and reduced virtual space. Reduced virtual space is better safeguard against memory hogs and better memory/cache locality to reduce cache/page miss in theory.

Disadvantages of the unilib muslx32 platform

No binary exclusive packages work (e.g. adobe flash, spotify, genymotion, virtualbox, etc.) since no major distro currently completely supports it so no incentive to offer a x32 ABI version. Some SIMD assembly optimizations are not enabled. Some assembly based packages don't work because they need to be hand edited. It is not multilib meaning that there may be problems with packages that only offer x86 or x86_64 like wine [which has no x32 support].

For Adobe Flash try using Shumway Firefox addon. It may or not work for some content.

It should be possible to run glibc only programs with chroot, so you can use spotify in that.

Who should use muslx32?

Early adopters of 64 bit and older PCs and laptops

Those that enjoy the challenge of fixing bugs especially assembly bugs and those related to musl.

Who should not use muslx32?

Whenver there is high risk involved. Some situations like online test taking require Adobe Flash to work. Online banking and commerce or online shopping, you should not use this because the browser Firefox is outdated and hard to fix.

Other recommendations

Use -Os and use kernel z3fold to significantly reduce swapping. Use cache to ram for Firefox if using Gentoo from a usbstick.

Sources and credits of patches

Some patches for musl libc and x32 came from Alpine Linux (Natanael Copa), Void Linux, debian x32 port (Adam Borowski), musl overlay (Anthony G. Basile/blueness), musl-extras (Aric Belsito/lluixhi)) .... (will update this list)

What you can do to help?

  • Clean the ebuilds with proper x32 ABI and musl CHOST checks and submit them to Gentoo.
  • Write/Fix assembly code for the jit based packages and assembly based packages.
  • Test and patch new ebuilds for these use cases or stakeholders: server, web, gaming, etc, entertainment, developer, science, business, graphic artists.
  • Check and fix packages that use elf_x86_64 when it should link using elf32_x86_64.
  • Check and fix packages that use constant numbers for syscalls. The syscall needs to added/or'ed by __X32_SYSCALL_BIT or 0x40000000.
  • Check all sizeof(void*) and similar to be sure they are in the 4G address range if porting from 64 bit code.
  • Replace all important longs that assume 64-bit as long long. In x32, long is actual 4 bytes.
  • Check and fix the build system scripts--inspect both the linker flags and the compiler flags and constants--if it did not provide a special case for x32 ABI.
  • Convert ebuilds to multilib to cross compile them if it fails to work on x32 ABI. Make corrections to these packages in profiles/default/linux/musl/amd64/x32/package.use.force .

Where can we meet on IRC?

#gentoo-muslx32 on freenode

Working packages

Here are some major packages listed that may be difficult to port but happen to work.

package | notes --- | --- strace | It depends on musl from this overlay since bits/user.h is broken in musl. gdb | It depends on musl from this overlay since bits/user.h is broken in musl. X | You need to copy configs/20-video.conf from muslx32toolkit to etc/X11/xorg.conf.d/20-video.conf and edit it especially the Hz and the driver. This special file loads the proper modules explicitly in the correct order instead of lazy loading them. DRI3 set to 1 breaks opengl so you may need to set it to 0. wpa_supplicant | Works as expected. Untested GUI if any. xf86-video-nouveau | Works on Geforce2 MX xf86-video-ati | Works if it doesn't pull proprietary drivers such as opencl (AMDAPP) or AMDGPU(-PRO) drivers. mplayer | Works when streaming radio mpd | Should work from past experience geany | Works showing IDE. dwm and dmenu | Works as expected. Moving windows to other virtual desktops. Dmenu loads menu immediate but not functioning at one instance after hours of use and cannot be loaded without killing X. xfce4 | Does show desktop. May possibly not log off first time but it fixes itself. aterm | Works only from this overlay. xfce4-terminal | Works as expected. gimp | Can draw with basic shapes. xscreensaver | Opengl screen savers tested working. mesa-progs | Glxgears works on working opengl. chrony and ntpd | Chrony needs musl struct timex patched with musl from this overlay. don't forget to grab the timezone-data package and set /etc/timezone. alsa | You may need to copy _.asound.rc to /<user>/.asound.rc to get sound working for Firefox. It works without .asound.rc with mplayer. gnu screen | Allows to copy and paste and have multiple apps run in each virtual terminal links | Works when downloading and viewing pages lxde-meta | Works on load and with menu lanucher evince | Works showing pdf inkscape | Works when drawing basic shapes. wireshark | Works when displaying when opening pcap. Untested for capturing. audacious | Works when playing mp3 pidgin | Works with aim GPicView | Showed picture without segfault. gucharmap | Works showing characters PCManFM | Works viewing directory. vlc | Works when playing video keepassx | Works but needs qtcore and qtgui patch applied to properly display folders. leafpad | Works on save and load file emacs | May be slow loading but it should work. Tested under chroot but not native. vi | It should work. Tested under chroot but no

Related Skills

View on GitHub
GitHub Stars10
CategoryDevelopment
Updated3mo ago
Forks3

Languages

Shell

Security Score

72/100

Audited on Dec 9, 2025

No findings