From 9d3463434b883ef8f89386d76e1e40e63e9e945c Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Mon, 14 Oct 2024 15:36:49 +0100
Subject: [PATCH] pv-runtime: Use host versions of the libdrm family, if newer

In current Mesa versions, typically these are pulled in via explicit
linking that generates a `DT_NEEDED` ELF header, either in individual
DRI drivers in very old Mesa, in the Gallium "megadriver" in
intermediate Mesa versions like the one in Debian 12, or in
`libgallium-${VERSION}.so` in newer Mesa.

However, Mesa merge request
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21658
suggests demoting the dependency on `libdrm_amdgpu.so.1` from
`DT_NEEDED` to `dlopen()`. Changing that dependency from declarative to
imperative breaks our ability to follow it, resulting in the container's
older `libdrm_amdgpu.so.1` being used.

In principle there's nothing to stop the same thing from happening for
any of the libraries in the libdrm family, so look for all of them.
For future-proofing, I've included all available drivers even if they
are not available on x86 (but excluding exynos and omap, which seem to
be only for 32-bit ARM hardware, which is probably no longer
interesting).

Tested-by: Dmitry Osipenko
Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 pressure-vessel/runtime.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/pressure-vessel/runtime.c b/pressure-vessel/runtime.c
index 3a1dadd47..ac9df5997 100644
--- a/pressure-vessel/runtime.c
+++ b/pressure-vessel/runtime.c
@@ -5374,6 +5374,17 @@ collect_graphics_libraries_patterns (GPtrArray *patterns)
     "libva-drm.so.2",
     "libva-glx.so.2",
     "libva-x11.so.2",
+
+    /* Dependencies that might come in via dlopen() */
+    "libdrm.so.2",
+    "libdrm_amdgpu.so.1",
+    "libdrm_etnaviv.so.1",
+    "libdrm_freedreno.so.1",
+    "libdrm_intel.so.1",
+    "libdrm_nouveau.so.2",
+    "libdrm_radeon.so.1",
+    "libdrm_tegra.so.0",
+
   };
   static const char * const sonames_even_if_older[] =
   {
-- 
GitLab