-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos: Don't set LD_LIBRARY_PATH for graphics drivers that don't need it. #61981
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted us to arrive to this for quite some time, nice!
… it. A new internal option `hardware.opengl.setLdLibraryPath` is added which controls if `LD_LIBRARY_PATH` should be set to `/run/opengl-driver(-32)/lib`. It is false by default and is meant to be set to true by any driver which requires it. If this option is false, then `opengl.nix` and `xserver.nix` will not set `LD_LIBRARY_PATH`. Currently Mesa and NVidia drivers don't set `setLdLibraryPath` because they work with libglvnd and do not override libraries, while `amdgpu-pro`, `ati` and `parallels-guest` set it to true (the former two really need it, the last one doesn't build so is presumed to). Additionally, the `libPath` attribute within entries of `services.xserver.drivers` is removed. This made `xserver.nix` add the driver path directly to the `LD_LIBRARY_PATH` for the display manager (including X server). Not only is it redundant when the driver is added to `hardware.opengl.package` (assuming that `hardware.opengl.enable` is true), in fact all current drivers except `ati` set it incorrectly to the package path instead of package/lib. This removal of `LD_LIBRARY_PATH` could break certain packages using CUDA, but only those that themselves load `libcuda` or other NVidia driver libraries using `dlopen` (not if they just use `cudatoolkit`). A few have already been fixed but it is practically impossible to test all because most packages using CUDA are libraries/frameworks without a simple way to test. Fixes NixOS#11434 if only Mesa or NVidia graphics drivers are used.
6afa4ce
to
370d3af
Compare
Updated to make the option internal. |
What is the problem with setting |
Unnecessary overhead looking for libraries in those folders (on 64-bit systems, this may involve actually finding the library and then figuring out it's not for the right architecture). Potential to result in overriding libraries that were not intended to be. And generally we shouldn't be setting environment variables that are not needed. |
This change caused breakage of 32-bit apps due to incorrect patchelf-ing in nvidia-x11, will be fixed by #62859. |
@ambrop72 Is this one ready to go? |
@matthewbauer Mostly, but I figured no one tested if mesa drivers still work so let me first do a sanity test on a different machine. I can't test ati drivers though. But in all theory it should not break. |
Yeah I wish we had better automated tests for this stuff, but I don't think it would be possible without actually having the hardware available. |
I can test "amdgpu", including 32-bit. |
For now I tried various stuff just by unsetting the variable when running them. There's this risk that older versions (that still require the variable) will stop working for people, but that sounds OK-ish, as it's a long time now IIRC and people can work around simply by setting the variable manually or finally updating. |
I will test this with Intel and AMD graphics very soon, however, we first need to merge #62870, or NVidia will break. |
Sorry that was not completely correct because those dispatch libraries currently use |
Tested these drivers (
|
Nitpick: I wonder if all the glvnd-related changes are worth a summary sentence in release notes, perhaps describing all together. (Perhaps later when RUNPATH is included.) |
Agree. Also pending is removal of XDG_DATA_DIRS from opengl.nix which can be done because of #62869. |
I think this should be merged. Everything I could possibly test works perfectly. |
A new option
hardware.opengl.setLdLibraryPath
is added which controls ifLD_LIBRARY_PATH
should be set to/run/opengl-driver(-32)/lib
. It is false by default and is meant to be set to true by any driver which requires it. If this option is false, thenopengl.nix
andxserver.nix
will not setLD_LIBRARY_PATH
.Currently Mesa and NVidia drivers don't set
setLdLibraryPath
because they work with libglvnd and do not override libraries, whileamdgpu-pro
,ati
andparallels-guest
set it to true (the former two really need it, the last one doesn't build so is presumed to).Additionally, the
libPath
attribute within entries ofservices.xserver.drivers
is removed. This madexserver.nix
add the driver path directly to theLD_LIBRARY_PATH
for the display manager (including X server). Not only is it redundant when the driver is added tohardware.opengl.package
(assuming thathardware.opengl.enable
is true), in fact all current drivers exceptati
set it incorrectly to the package path instead of package/lib.This removal of
LD_LIBRARY_PATH
could break certain packages using CUDA, but only those that themselves loadlibcuda
or other NVidia driver libraries usingdlopen
(not if they just usecudatoolkit
). A few have already been fixed but it is practically impossible to test all because most packages using CUDA are libraries/frameworks without a simple way to test.Fixes #11434 if only Mesa or NVidia graphics drivers are used.
Motivation for this change
LD_LIBRARY_PATH
needs to go away.Things done
Tested this with my desktop system with NVidia and observed no problems, including running various programs using OpenGL, Vulkan, VDPAU, CUDA and OpenCL. It would benefit from testing with other drivers.
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)