Making musl and proprietary NVIDIA drivers work together
本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。
Making musl and proprietary NVIDIA drivers work together
06.11.2026 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.
2026年11月6日,正如您可能了解到的,基于 musl 的发行版存在一个局限性,即在配备各种 NVIDIA 显卡的计算机上使用时,它们无法发挥应有的性能。这是因为该驱动程序具有专有性质,且是为 glibc 构建的。我一直在尝试解决这个问题,本文是对这一工作的总结。
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.
背景:NVIDIA 显卡在 Linux 上比较棘手。虽然大多数其他 GPU 供应商默认使用自由软件图形驱动程序(内核驱动程序位于 Linux 内核源码树中,用户空间部分由 Mesa 项目提供),但 NVIDIA 通常不这样做,而是依赖于内核树外的驱动程序以及由供应商提供的专有用户空间库。
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.
确实存在名为 Nouveau(内核和 OpenGL Mesa 驱动程序)和 NVK(Vulkan 驱动程序)的自由软件驱动程序。这使得显卡可以工作,但由于各种原因,性能通常会显著降低。目前的情况很大程度上取决于您所使用的 NVIDIA 显卡代次。
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).
简而言之:现代系统上的专有驱动程序不支持 Maxwell(GTX 700 系列)之前的任何显卡;Nouveau 对其有一定程度的支持,但由于目前维护不善,可能会出现问题;在能正常工作时,性能尚可。Maxwell(GTX 700 和 900 系列)和 Pascal(GTX 1000 系列)由专有驱动程序的旧版 580 分支完全支持,该分支也支持较新的硬件。它们可以使用 Nouveau,但性能非常差,因为显卡无法从极低的启动频率进行升频(这需要 NVIDIA 从未发布的固件)。
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. Other than that, the experience is often okay, particularly with NVK.
Turing(GTX 1600 系列和 RTX 2000 系列)及更新的显卡由当前的专有驱动程序主分支(撰写本文时为 620)以及旧版(580)分支支持,同时也由 Nouveau 支持,因为这些显卡使用包含在 linux-firmware 中的 GSP 固件。然而,使用自由开源驱动程序意味着只能获得专有驱动程序 40-80% 的性能。除此之外,使用体验通常还可以,尤其是使用 NVK 时。
In even shorter, if you have RTX 2000 and above you are mostly okay with FOSS but lose performance, if you have newer than GTX 600 but older than GTX 1600 you are screwed and need the proprietary driver, if your card is really old it may or may not work well and you may not be able to use it at all.
更简单地说:如果您拥有 RTX 2000 及以上显卡,使用自由开源驱动程序基本没问题,但会损失性能;如果您拥有比 GTX 600 新但比 GTX 1600 旧的显卡,那您就麻烦了,必须使用专有驱动程序;如果您的显卡非常老,它可能工作良好也可能不行,甚至可能完全无法使用。
Proprietary drivers and musl We now have a pull request open for both the 580 and 620 branch. It is not yet entirely ready but works, and is available for x86_64 and aarch64 architectures as NVIDIA supplies it. To get there, there were multiple things to take care of. Particularly, using stock musl is out of the question and will likely never work. I will elaborate on each thing.
专有驱动程序与 musl:我们现在针对 580 和 620 分支都开启了合并请求。虽然尚未完全准备好,但已经可以工作,并且正如 NVIDIA 所提供的那样,适用于 x86_64 和 aarch64 架构。为了实现这一点,需要处理多项事务。特别是,使用原版 musl 是不可能的,而且很可能永远无法工作。我将详细说明每一项。
GLVND The GLVND library was created by NVIDIA to allow for vendor-neutral OpenGL dispatch. It provides the libraries that applications link and exposes the OpenGL (and other) API. It then dispatches the calls to the implementations, which may be e.g. Mesa or the proprietary driver. Most distributions nowadays use GLVND. Mesa comes with its own builtin dispatch code and does not necessarily require GLVND if you don’t build it with it. Musl distributions in general use this.
GLVND:GLVND 库由 NVIDIA 创建,旨在实现供应商中立的 OpenGL 分发。它提供了应用程序链接的库,并公开了 OpenGL(及其他)API。然后,它将调用分发给具体的实现,例如 Mesa 或专有驱动程序。如今大多数发行版都使用 GLVND。Mesa 自带内置的分发代码,如果您不使用 GLVND 构建它,则不一定需要它。Musl 发行版通常使用此库。
Chimera at this point does not, and Void Linux on musl does not as it shares packaging with the glibc branch. Chimera switched to GLVND on November 5 2026. Switching is rather straightforward and does not need much documentation. One just has to package GLVND, rebuild Mesa with it (to avoid using its builtin dispatch libraries) and take care of packages that have dependencies on mesa-devel.
Chimera 目前尚未使用,而 Void Linux 的 musl 版本也没有使用,因为它与 glibc 分支共享打包方式。Chimera 于 2026 年 11 月 5 日切换到 GLVND。切换过程相当简单,不需要太多文档。只需打包 GLVND,使用它重新构建 Mesa(以避免使用其内置的分发库),并处理那些依赖于 mesa-devel 的软件包即可。
GLVND is not only useful for NVIDIA drivers, but in general it is the primary thing users will find useful. There are also some vendor drivers on ARM and elsewhere but those are niche. The proprietary drivers mandate GLVND since many years back (this is also very useful on laptops with hybrid graphics, because then you may still want to keep Mesa for the iGPU).
GLVND 不仅对 NVIDIA 驱动程序有用,而且通常是用户会觉得有用的主要内容。在 ARM 和其他平台上也有一些供应商驱动程序,但那些属于小众。专有驱动程序多年来一直强制要求使用 GLVND(这在配备混合显卡的笔记本电脑上也很有用,因为您可能仍希望保留 Mesa 来驱动集成显卡)。
Gcompat The gcompat project provides a compatibility shim to allow for limited usage of programs linked with glibc. It consists of two components: the loader, which acts as the dynamic linker (ldso) for the programs. For example, on x86_64, glibc programs expect ld-linux-x86_64.so.2 as their dynamic linker. The loader does not do much, as it only sets up a library preload for the below, and execs into the real musl one.
Gcompat:gcompat 项目提供了一个兼容性垫片,允许有限度地使用与 glibc 链接的程序。它由两个组件组成:加载器,充当程序的动态链接器 (ldso)。例如,在 x86_64 上,glibc 程序期望 ld-linux-x86_64.so.2 作为其动态链接器。加载器本身不做太多工作,它只是为下面的组件设置库预加载,并执行真正的 musl 加载器。
the shim library, libgcompat.so.0, which implements various symbols that are in glibc and used by programs, but not in musl. It does not implement everything. It is what provides the bulk of the functionality, and is useed by the means of LD_PRELOAD, automatically by the loader. Unfortunately for us, the latest tagged release of gcompat does not provide all the symbols the proprietary drivers require to resolve. Fortunately for us, the latest Git branch does. The development nowadays is very slow so we just bumped it up to the latest revision.
垫片库 libgcompat.so.0,它实现了 glibc 中存在且被程序使用,但在 musl 中不存在的各种符号。它并没有实现所有内容。它提供了大部分功能,并通过 LD_PRELOAD 的方式由加载器自动使用。不幸的是,gcompat 的最新标记版本并未提供专有驱动程序解析所需的所有符号。幸运的是,最新的 Git 分支提供了。目前的开发进度非常缓慢,所以我们直接将其升级到了最新版本。
Patchelf and initial packaging You can see how the packaging works in the pull request, and that part is rather unimportant for now, and does not require elaboration. It works in a similar way to other distros, downloading the .run archive from NVIDIA and installing everything to the correct places. Of course, in our case, we cannot install it directly, because it depends on glibc and other stuff. We also can’t just pull in gcompat as is, because most of the driver is libraries that have no interpreter.
Patchelf 和初始打包:您可以在合并请求中看到打包的工作方式,这部分目前不太重要,无需赘述。它的工作方式与其他发行版类似,即从 NVIDIA 下载 .run 归档文件并将所有内容安装到正确的位置。当然,在我们的情况下,我们不能直接安装它,因为它依赖于 glibc 和其他东西。我们也不能直接引入 gcompat,因为驱动程序的大部分是没有任何解释器的库。
Let’s see what happens if we run ldd on libnvidia-glcore.so.580.196.07, which is the core OpenGL library. $ ldd libnvidia-glcore.so.580.196.07 ldd (0x739c4a8b1000) libm.so.6 => ldd (0x739c4a8b1000) libc.so.6 => ldd (0x739c4a8b1000) libdl.so.2 => ldd (0x739c4a8b1000) libnvidia-tls.so.580.196.07 => /lib/libnvidia-tls.so.580.196.07 (0x739c4a8a3000) libnvidia-gpucomp.so.580.196.07 => /lib/libnvidia-gpucomp.so.580.196.07 (0x739c3fa00000) libpthread.so.0 => ldd (0x739c4a8b1000) librt.so.1 => ldd (0x739c4a8b1000) Error loading shar
让我们看看如果对 libnvidia-glcore.so.580.196.07(核心 OpenGL 库)运行 ldd 会发生什么。$ ldd libnvidia-glcore.so.580.196.07 ldd (0x739c4a8b1000) libm.so.6 => ldd (0x739c4a8b1000) libc.so.6 => ldd (0x739c4a8b1000) libdl.so.2 => ldd (0x739c4a8b1000) libnvidia-tls.so.580.196.07 => /lib/libnvidia-tls.so.580.196.07 (0x739c4a8a3000) libnvidia-gpucomp.so.580.196.07 => /lib/libnvidia-gpucomp.so.580.196.07 (0x739c3fa00000) libpthread.so.0 => ldd (0x739c4a8b1000) librt.so.1 => ldd (0x739c4a8b1000) 加载共享库时出错