Skip to content

pressure-vessel: Look for internal Nvidia helper libraries by name

Simon McVittie requested to merge wip/smcv/nvidia-by-name into main

The Nvidia drivers have various helper libraries that get loaded as dependencies. Some of them are hard dependencies via DT_NEEDED, but others are loaded dynamically with dlopen(): for example, at the time of writing, libGLX_nvidia.so.0 has a DT_NEEDED dependency on libnvidia-glcore.so.VERSION which is sufficient for OpenGL, but dlopens libnvidia-glvkspirv.so.VERSION when asked to act as a Vulkan driver.

Normally, we can find these libraries by their entry in soname_globs_even_if_older[], by using the soname-match: syntax to search /etc/ld.so.cache for SONAMEs matching a glob pattern like libnvidia-glvkspirv.so.*. This works because OS distributions normally install these libraries into the default system library directory /usr/lib{,32,64} or /usr/lib/MULTIARCH, which is indexed by ldconfig(8).

However, when using Canonical's Snap apps, the Nvidia drivers can only be found in the LD_LIBRARY_PATH, and soname-match: does not implement LD_LIBRARY_PATH search. This leads to a situation similar to https://github.com/ValveSoftware/steam-runtime/issues/632 where these libraries are not found. The result is that the Nvidia Vulkan driver is present, but fails to load.

If we can read /sys/module/nvidia/version (which Flatpak also relies on as its way to discover the current Nvidia driver version), then we can resolve this by looking for each of the known libraries by name. This takes into account LD_LIBRARY_PATH and DT_RUNPATH, not just the ld.so.cache. Making this effective will require a snapd change, to make /sys/module/nvidia/version readable.

Helps: https://github.com/ValveSoftware/steam-runtime/issues/586


/cc @denittis @dadap @cubanismo

Merge request reports