Making musl and proprietary NVIDIA drivers work together
Key points
Chimera Linux has a pull request open that packages NVIDIA's proprietary driver, both the 580 and 620 branches, for its musl-based system on x86_64 and aarch64. It is not finished but already works. The post explains what stood in the way and how each problem was solved, mostly by patching the binaries and using a modified musl.
Which cards need the proprietary driver
- Cards older than Maxwell (before the GTX 700 series) are not supported by the proprietary driver on modern systems. Nouveau may run them, but it is poorly maintained for these chips.
- Maxwell (GTX 700/900) and Pascal (GTX 1000) cards are fully supported only by the legacy 580 branch. Under Nouveau they cannot leave their low boot clocks because NVIDIA never released the needed firmware, so performance is very poor.
- Turing (GTX 1600, RTX 2000) and newer cards work with the current 620 branch, the 580 branch, and Nouveau/NVK using GSP firmware from linux-firmware. The free stack reaches roughly 40–80% of proprietary performance.
GLVND
- Chimera switched to GLVND on November 5 2026. This involved packaging GLVND, rebuilding Mesa against it in place of Mesa's own dispatch, and adjusting packages that depend on
mesa-devel. - The proprietary driver requires GLVND. It also lets hybrid-graphics laptops keep Mesa for the integrated GPU.
gcompat
- gcompat supplies a loader that stands in for the glibc dynamic linker and a preloaded shim,
libgcompat.so.0, that provides glibc-only symbols. - The last tagged release lacks symbols the driver needs, so Chimera moved to the latest Git revision.
Binary patching
- The driver is unpacked from NVIDIA's .run archive, as on other distributions.
patchelfis run on every installed library and executable. It removes the glibc-specific dependencies (ld-linux-x86-64.so.2,libdl.so.2,libm.so.6,libpthread.so.0,librt.so.1), pointslibc.so.6atlibc.so, and addslibgcompat.so.0.- For the 620 driver, a few references to
libstdc++.so.6(used for operator new) are replaced with the ABI-compatiblelibc++abi.so.1.
**Changes to musl (musl-nvidia)**
- Stock musl is ruled out, and the author expects it will never work.
- The driver uses GNU ifunc relocations (
R_X86_64_IRELATIVE). musl leaves these out on purpose for security reasons. - Ifunc handling was added from Alpaquita Linux's
musl-perfpatches, using only the x86_64 patch and its aarch64 counterpart. The result is packaged asmusl-nvidia. libnvidia-glcoreandlibnvidia-tlsuse initial-exec (static) TLS. musl refuses todlopensuch libraries, while glibc reserves spare static TLS space for them.- Chimera patched the dynamic linker to handle this. When a library flagged
DF_STATIC_TLSis loaded, the linker places its TLS image in spare static TLS space if there is room, instead of allocating dynamic TLS.
**Mutex shim (libnvcompat)**
- After the steps above, graphical programs hung. The driver relies on glibc's static recursive mutex initializer (
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP), which musl does not support. - A new library,
libnvcompat, wrapspthread_mutex_lock,pthread_mutex_timedlockandpthread_mutex_trylock. Before locking, it copies the glibc "kind" field, which musl does not use, into musl's type field if the type is still unset. - glibc adaptive mutexes are treated as regular ones.
- The driver's calls are redirected to the wrappers with
patchelf --rename-dynamic-symbols, andlibnvcompatis added as a dependency of every driver library.
Open-source parts packaged separately
nvidia-xconfig,nvidia-settings,nvidia-modprobe,nvidia-persistenced,egl-gbmandegl-waylandare built from source as their own packages. This reduces how much needs shimming, and the driver package depends on them.
Status and testing
- The 580 driver was tested on a GTX 980 Ti in an i3-7100 machine and works.
- Users report the 620 driver working with an RTX 3070 Ti and at least partly working on AArch64.
- The packaging still needs refinement and more testing, and the pull request has not been merged.
Summary by DistroNews, based on the original post.
As you may be aware, one of the limitations of musl-based distributions is that they will not function to their proper extent when used in computers with various NVIDIA graphics cards. This is due to the proprietary nature of the driver, being built for glibc. I have been experimenting with trying to make this work, and this post is the summary of that effort. Context The NVIDIA graphics cards are tricky on Linux. While most other GPU vendors by default use free software graphics drivers (with kernel drivers in-tree in Linux, and userspace supplied by the Mesa project), NVIDIA in general does not, relying on an out of tree kernel driver and proprietary userland libraries that are supplied by the vendor. A free software driver does exist, called Nouveau (kernel and OpenGL Mesa driver) and NVK (Vulkan driver). This allows the cards to work, but usually with significantly reduced performance, due to various reasons. Currently the state depends significantly on what generation of NVIDIA card you have. In short: Anything older than Maxwell (GTX 700 series) is unsupported by the proprietary driver on modern systems, and supported to some extent by Nouveau, but may have issues due to poor maintenance nowadays; performance should be okay when it works. Maxwell (GTX 700 and 900 series) and Pascal (GTX 1000 series) is supported fully by the legacy 580 branch of the proprietary driver, which also supports newer hardware. It works with Nouveau, but with very poor performance, as the cards can never reclock from their very low boot clocks (which would require firwmare that NVIDIA never released). Turing (GTX 1600 series and RTX 2000 series) and anything newer is supported by the current main proprietary driver branch (at the time of writing, 620) as well as the legacy (580) branch, and by Nouveau, as these cards use the GSP firmware that is included in linux-firmware. However, using the FOSS driver means only getting 40-80% of the proprietary driver’s performance.
This is the opening of the story. The full text is on the original page.
Read the original at chimera-linux.org