Question regarding RUNPATH and graphics driver configuration files

Background

I was trying to debug an issue I was having in the interaction between Kodi and libnvidia-egl-gbm. I tried to LD_PRELOAD a different version of libnvidia-egl-gbm.so.1 when starting Kodi to have an easier time debugging and test my potential fix only to be confused that my LD_PRELOAD (or LD_LIBRARY_PATH) environment variables where seemingly not getting picked up. After a while I found out that libEGL.so was dlopening libnvidia-egl-gbm.so.1 using its full path instead of simply using the object name. This is because (in my Nvidia setup) /share/egl/egl_external_platform.d/15_nvidia_gbm.json in nvidia-x11 is modified to not only provide the name of the object but the full path to it.

My question

This change seems to indicate that this was deliberate decision. I understand that this was because GNU ld doesn’t respect LD_LIBRARY_PATH in setuid binaries. So wrapper scripts which set that libraries don’t work in that case. I don’t understand why the PR does not consider the option of setting RUNPATH in the libraries which perform the dlopen.

Wouldn’t it be better to not modify the library name config files shipped by upstream and rely on properly setting RUNPATH in the libraries that dlopen the drivers?

This would have the following advantages:

  1. Align NixOS behavior with other distributions. Other distributions rely on RUNPATH to locate the drivers and thus have a more predictable behavior as well as support overriding them using LD_PRELOAD.
  2. Better abstraction between consumers and producers of driver configuration files. Currently consumers (my knowledge is somewhat superficial and I could only find libglvnd) rely on a NixOS specific modification made to every single driver shipped in NixOS and every single driver also needs to have this modification done to it. It would reduce maintenance burden if the already established abstraction (RUNPATH) was used.

If others think this is something that would make sense, I’d be happy to try to implement this change in nixpkgs.