Skip to content

nvidiaLegacy340 not working: using the wrong libGL.so file #120602

Open

Description

@wagnerf42

Describe the bug

the nvidia legacy 340 does not work (has been failing for a long time).
i recently got a newer (still legacy 340) gpu but it did not affect the issue.
i'm currently on nixos 20.09.

launching any opengl app fails.
glxgears for example tells me "couldn't get an rgb double buffered visual".

However if I look closer it's not using the right libGL.so :

ldd /nix/store/v9ndzvazn5fb8762a2r15zna5hy35429-glxinfo-8.4.0/bin/glxgears
linux-vdso.so.1 (0x00007ffddef5d000)
libGL.so.1 => /nix/store/rqa88mn1vmmxypw001sa0rx116ivrvf7-libGL-1.3.2/lib/libGL.so.1 (0x00007f0f726da000)

if i export LD_LIBRARY_PATH to LD_LIBRARY_PATH="/run/opengl-driver/lib:/run/opengl-driver-32/lib" then everything starts working.

i'm not sure how opengl dynamic libraries are supposed to work but is there a way to fix this ?

To Reproduce
nothing special to do. just use services.xserver.videoDrivers = ["nvidiaLegacy340"];

Expected behavior
opengl should work. i guess ldd on glxgears should redirect to the good libGL.so

Notify maintainers

@baracoder

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.4.107, NixOS, 20.09.3588.d395190b24b (Nightingale)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.10
  • channels(root): "musnix, nixpkgs-20.09.3588.d395190b24b"
    warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixos' does not exist, ignoring
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixpkgs

Activity

  1. added
    0.kind: bug
    on Apr 25, 2021
  2. baracoder commented on Apr 26, 2021

    @baracoder
    Contributor

    🤔 on current nixos-unstable I get this for glxgears

     ldd `which glxgears`|grep -i libgl 
    	libGL.so.1 => /nix/store/v3xi47p44wfdgc06hw9i90nqdja7d2xn-libGL-1.3.2/lib/libGL.so.1 (0x00007f26c37ce000)
    	libGLX.so.0 => /nix/store/w4ydr5lczfnqkz1dg3ga0gakiddzbqh7-libglvnd-1.3.2/lib/libGLX.so.0 (0x00007f26c334e000)
    	libGLdispatch.so.0 => /nix/store/w4ydr5lczfnqkz1dg3ga0gakiddzbqh7-libglvnd-1.3.2/lib/libGLdispatch.so.0 (0x00007f26c3280000)
    

    starting glxgears with strace

    strace glxgears 2>&1|egrep -i 'libgl|nvidia|icd|opengl'|grep -v 'ENOENT'
    openat(AT_FDCWD, "/nix/store/v3xi47p44wfdgc06hw9i90nqdja7d2xn-libGL-1.3.2/lib/libGL.so.1", O_RDONLY|O_CLOEXEC) = 3
    openat(AT_FDCWD, "/nix/store/w4ydr5lczfnqkz1dg3ga0gakiddzbqh7-libglvnd-1.3.2/lib/libGLX.so.0", O_RDONLY|O_CLOEXEC) = 3
    openat(AT_FDCWD, "/nix/store/w4ydr5lczfnqkz1dg3ga0gakiddzbqh7-libglvnd-1.3.2/lib/libGLdispatch.so.0", O_RDONLY|O_CLOEXEC) = 3
    openat(AT_FDCWD, "/run/opengl-driver/lib/libGLX_nvidia.so.0", O_RDONLY|O_CLOEXEC) = 4
    openat(AT_FDCWD, "/nix/store/05h8rrxpxmsg84pg7mnm1bw4w4b54fp3-nvidia-x11-460.73.01-5.11.14/lib/libnvidia-tls.so.460.73.01", O_RDONLY|O_CLOEXEC) = 4
    openat(AT_FDCWD, "/nix/store/05h8rrxpxmsg84pg7mnm1bw4w4b54fp3-nvidia-x11-460.73.01-5.11.14/lib/libnvidia-glcore.so.460.73.01", O_RDONLY|O_CLOEXEC) = 4
    openat(AT_FDCWD, "/etc/nvidia/nvidia-application-profiles-rc", O_RDONLY) = 4
    openat(AT_FDCWD, "/nix/store/w4ydr5lczfnqkz1dg3ga0gakiddzbqh7-libglvnd-1.3.2/lib/libGL.so.1.7.0", O_RDONLY) = 4
    openat(AT_FDCWD, "/nix/store/w4ydr5lczfnqkz1dg3ga0gakiddzbqh7-libglvnd-1.3.2/lib/libGLX.so.0.0.0", O_RDONLY) = 4
    openat(AT_FDCWD, "/nix/store/w4ydr5lczfnqkz1dg3ga0gakiddzbqh7-libglvnd-1.3.2/lib/libGLdispatch.so.0.0.0", O_RDONLY) = 4
    openat(AT_FDCWD, "/nix/store/05h8rrxpxmsg84pg7mnm1bw4w4b54fp3-nvidia-x11-460.73.01-5.11.14/lib/libGLX_nvidia.so.460.73.01", O_RDONLY) = 4
    openat(AT_FDCWD, "/nix/store/05h8rrxpxmsg84pg7mnm1bw4w4b54fp3-nvidia-x11-460.73.01-5.11.14/lib/libnvidia-tls.so.460.73.01", O_RDONLY) = 4
    openat(AT_FDCWD, "/nix/store/05h8rrxpxmsg84pg7mnm1bw4w4b54fp3-nvidia-x11-460.73.01-5.11.14/lib/libnvidia-glcore.so.460.73.01", O_RDONLY) = 4
    openat(AT_FDCWD, "/nix/store/05h8rrxpxmsg84pg7mnm1bw4w4b54fp3-nvidia-x11-460.73.01-5.11.14/lib/libGLX_nvidia.so.460.73.01", O_RDONLY) = 4
    openat(AT_FDCWD, "/nix/store/05h8rrxpxmsg84pg7mnm1bw4w4b54fp3-nvidia-x11-460.73.01-5.11.14/lib/libGLX_nvidia.so.460.73.01", O_RDONLY) = 5
    openat(AT_FDCWD, "/nix/store/05h8rrxpxmsg84pg7mnm1bw4w4b54fp3-nvidia-x11-460.73.01-5.11.14/lib/libnvidia-glcore.so.460.73.01", O_RDONLY) = 4
    openat(AT_FDCWD, "/nix/store/05h8rrxpxmsg84pg7mnm1bw4w4b54fp3-nvidia-x11-460.73.01-5.11.14/lib/libnvidia-glcore.so.460.73.01", O_RDONLY) = 5
    connect(4, {sa_family=AF_UNIX, sun_path=@"var/run/nvidia-xdriver-2f9b7124\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 66) = 0
    connect(5, {sa_family=AF_UNIX, sun_path=@"var/run/nvidia-xdriver-2f9b7124\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 66) = 0
    openat(AT_FDCWD, "/nix/store/w4ydr5lczfnqkz1dg3ga0gakiddzbqh7-libglvnd-1.3.2/lib/libGL.so.1.7.0", O_RDONLY) = 6
    openat(AT_FDCWD, "/nix/store/w4ydr5lczfnqkz1dg3ga0gakiddzbqh7-libglvnd-1.3.2/lib/libGLX.so.0.0.0", O_RDONLY) = 6
    openat(AT_FDCWD, "/nix/store/w4ydr5lczfnqkz1dg3ga0gakiddzbqh7-libglvnd-1.3.2/lib/libGLdispatch.so.0.0.0", O_RDONLY) = 6
    openat(AT_FDCWD, "/nix/store/05h8rrxpxmsg84pg7mnm1bw4w4b54fp3-nvidia-x11-460.73.01-5.11.14/lib/libGLX_nvidia.so.460.73.01", O_RDONLY) = 6
    openat(AT_FDCWD, "/nix/store/05h8rrxpxmsg84pg7mnm1bw4w4b54fp3-nvidia-x11-460.73.01-5.11.14/lib/libnvidia-tls.so.460.73.01", O_RDONLY) = 6
    openat(AT_FDCWD, "/nix/store/05h8rrxpxmsg84pg7mnm1bw4w4b54fp3-nvidia-x11-460.73.01-5.11.14/lib/libnvidia-glcore.so.460.73.01", O_RDONLY) = 6
    openat(AT_FDCWD, "/proc/driver/nvidia/params", O_RDONLY) = 6
    stat("/dev/nvidiactl", {st_mode=S_IFCHR|0666, st_rdev=makedev(0xc3, 0xff), ...}) = 0
    openat(AT_FDCWD, "/dev/nvidiactl", O_RDWR) = 6
    openat(AT_FDCWD, "/proc/driver/nvidia/params", O_RDONLY) = 7
    stat("/dev/nvidia-modeset", {st_mode=S_IFCHR|0666, st_rdev=makedev(0xc3, 0xfe), ...}) = 0
    openat(AT_FDCWD, "/dev/nvidia-modeset", O_RDWR|O_CLOEXEC) = 7
    openat(AT_FDCWD, "/proc/driver/nvidia/params", O_RDONLY) = 8
    stat("/dev/nvidia0", {st_mode=S_IFCHR|0666, st_rdev=makedev(0xc3, 0), ...}) = 0
    openat(AT_FDCWD, "/dev/nvidia0", O_RDWR|O_CLOEXEC) = 8
    openat(AT_FDCWD, "/proc/driver/nvidia/params", O_RDONLY) = 9
    stat("/dev/nvidia0", {st_mode=S_IFCHR|0666, st_rdev=makedev(0xc3, 0), ...}) = 0
    openat(AT_FDCWD, "/dev/nvidia0", O_RDWR|O_CLOEXEC) = 9
    openat(AT_FDCWD, "/dev/nvidia0", O_RDWR|O_CLOEXEC) = 10
    

    I don't know how it goes directly from

    openat(AT_FDCWD, "/nix/store/w4ydr5lczfnqkz1dg3ga0gakiddzbqh7-libglvnd-1.3.2/lib/libGLdispatch.so.0", O_RDONLY|O_CLOEXEC) = 3
    

    to

    openat(AT_FDCWD, "/run/opengl-driver/lib/libGLX_nvidia.so.0", O_RDONLY|O_CLOEXEC) = 4
    

    I think using LD_LIBRARY_PATH to select the driver was dropped in favor of libglvnd

    Might also be relevant https://github.com/NixOS/nixpkgs/blob/d600f006643e074c2ef1d72e462e218b647a096c/pkgs/build-support/add-opengl-runpath/setup-hook.sh

    It looks like the legacy driver does not contain any libGLX.so file, or it might be not copied due to the installation script.

    Unfortunately I can not test, as my card is not supported by the legacy driver.

  3. wagnerf42 commented on Apr 27, 2021

    @wagnerf42
    Author

    hi, thanks a lot for your help.

    i see that libglvnd
    uses addOpenGLRunpath to change the rpath for its libGLX.so

    i checked on my machine and this is indeed the case:

    ╭─wagnerf@trantor /run/opengl-driver/lib  
    ╰─➤  patchelf --print-rpath /nix/store/cavmwpp8zv4xn30qk8ih8fa1p0girjkg-libglvnd-1.3.2/lib/libGLX.so.0
    /run/opengl-driver/lib:/nix/store/mmay6kj3ysakrs1h02j96sflxrzy5h3a-libX11-1.6.12/lib:/nix/store/l0nk1kaf9a3gmdw6qjxzfgidrlfx7yf4-libXext-1.3.4/lib:/nix/store/cavmwpp8zv4xn30qk8ih8fa1p0girjkg-libglvnd-1.3.2/lib:/nix/store/0c7c96gikmzv87i7lv3vq5s1cmfjd6zf-glibc-2.31-74/lib
    

    that's good.

    but i'm wondering what this rpath is used for.

    running ldd on libglx i get:

    ╭─wagnerf@trantor /run/opengl-driver/lib  
    ╰─➤  ldd /nix/store/cavmwpp8zv4xn30qk8ih8fa1p0girjkg-libglvnd-1.3.2/lib/libGLX.so.0
            linux-vdso.so.1 (0x00007ffcb1bfa000)
            libX11.so.6 => /nix/store/mmay6kj3ysakrs1h02j96sflxrzy5h3a-libX11-1.6.12/lib/libX11.so.6 (0x00007fd434ba8000)
            libXext.so.6 => /nix/store/l0nk1kaf9a3gmdw6qjxzfgidrlfx7yf4-libXext-1.3.4/lib/libXext.so.6 (0x00007fd434b93000)
            libGLdispatch.so.0 => /nix/store/cavmwpp8zv4xn30qk8ih8fa1p0girjkg-libglvnd-1.3.2/lib/libGLdispatch.so.0 (0x00007fd434ada000)
            libdl.so.2 => /nix/store/0c7c96gikmzv87i7lv3vq5s1cmfjd6zf-glibc-2.31-74/lib/libdl.so.2 (0x00007fd434ad5000)
            libpthread.so.0 => /nix/store/0c7c96gikmzv87i7lv3vq5s1cmfjd6zf-glibc-2.31-74/lib/libpthread.so.0 (0x00007fd434ab4000)
            libc.so.6 => /nix/store/0c7c96gikmzv87i7lv3vq5s1cmfjd6zf-glibc-2.31-74/lib/libc.so.6 (0x00007fd4348f3000)
            libxcb.so.1 => /nix/store/h4frpi02xqd18z6snzfgkssimmsxd4cy-libxcb-1.13.1/lib/libxcb.so.1 (0x00007fd4348c8000)
            /nix/store/0c7c96gikmzv87i7lv3vq5s1cmfjd6zf-glibc-2.31-74/lib64/ld-linux-x86-64.so.2 (0x00007fd434d22000)
            libXau.so.6 => /nix/store/36r136kb1x3gjzdm58kv6fr9ym2qd3cg-libXau-1.0.9/lib/libXau.so.6 (0x00007fd4348c3000)
            libXdmcp.so.6 => /nix/store/0a0zf3rrm9824h2j8hlpfmjgwfawd00n-libXdmcp-1.1.3/lib/libXdmcp.so.6 (0x00007fd4348bb000)
    

    no one here is available in /run/opengl-driver

    do you have anything there going back to /run/opengl-driver ?

  4. wagnerf42 commented on Apr 27, 2021

    @wagnerf42
    Author

    ok, some more news.

    what is happening is that when launching glxgears it is asking the xserver what to use.
    using strace i can see
    access("/home/wagnerf/.Xauthority", R_OK) = 0
    and a bit below after chatting with X:
    openat(AT_FDCWD, "/run/opengl-driver/lib/tls/x86_64/x86_64/libGLX_indirect.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT

    so that's where the rpath is being used.
    it is because there is a dlopen on line 431 of libglxmapping.c in libglvnd.

    if i do the same strace an a working (non nvidia) machine it would follow the same pattern but open
    /run/opengl-driver/lib/libGLX_mesa.so.0 succesfully.

    so the rpath is good the only question is why is it trying to use libGLX_indirect (which does not exist) and not libGL

  5. wagnerf42 commented on Apr 27, 2021

    @wagnerf42
    Author

    it seems related to this

    they say that *glvnd is trying to fallback to a generic libGLX_indirect
    library if vendor-specific library doesn't exist or GLX_EXT_glvnd is not
    present *

    i checked using xdpyinfo -queryExtensions and the nvidia x server does not provide
    GLX_EXT_glvnd

    do you have this extension on your working nvidia card ?

  6. baracoder commented on Apr 27, 2021

    @baracoder
    Contributor

    Hm, don't have GLX_EXT_glvnd either

    xdpyinfo -queryExtensions | grep -i glx
        GLX  (opcode: 151, base event: 95, base error: 158)
        NV-GLX  (opcode: 155)
    

    also

    ldd /nix/store/*-libglvnd-1.3.2/lib/libGLX.so.0|grep opengl-driver
    

    does not find anything

  7. wagnerf42 commented on Apr 27, 2021

    @wagnerf42
    Author

    maybe we can just add two symbolic links to fix things up.
    like /run/opengl-driver/lib/libGLX_indirect.so.0 redirecting to /run/opengl-driver/lib/libGL.so
    and the same for 32bits repositories

  8. sigprof commented on Jun 8, 2021

    @sigprof
    Contributor

    Apparently the legacy 340 driver is marked as not supporting GLVND, but that useGLVND flag seems to affect only the driver build script and the primus and bumblebee packages.

    The services.xserver.videoDrivers = [ "nvidiaLegacy340" ]; option is obsolete; I needed to use these options in NixOS 21.05 instead:

    boot.kernelPackages = pkgs.linuxPackages_5_4;
    services.xserver.videoDrivers = [ "nvidia" ];
    hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_340;
    

    (Looks like the legacy 340 driver does not compile for the Linux 5.10.y kernel which is now the default version, so I needed to revert to Linux 5.4.y).

    And then I found another option which seems to fix the libGL problem:

    hardware.opengl.setLdLibraryPath = true;
    

    The description for hardware.opengl.setLdLibraryPath says that this option is supposed to be set by the OpenGL driver; however, the only places where this option is set are nixos/modules/hardware/video/amdgpu-pro.nix and nixos/modules/virtualisation/parallels-guest.nix. Maybe the NVIDIA driver module should also set this option when the legacy 340 version is selected?

  9. wagnerf42 commented on Jun 9, 2021

    @wagnerf42
    Author

    hey thanks for the help.

    so i tested hardware.opengl.setLdLibraryPath and it makes opengl work except for steam which is still broken.

    i'd rather be in favor of simply adding the two missing links.

  10. wagnerf42 commented on Jun 11, 2021

    @wagnerf42
    Author

    so i did a try with the links and it does not work.
    what we need to make it work is to replace libglvnd's libGL.so.1 by the one from NVidiaLegacy340.
    not sure how to do that but i'll give it more thoughts

  11. Irgendwer01 commented on Oct 1, 2021

    @Irgendwer01

    @wagnerf42 Any news on the issue with Steam? im having exactly the same on the latest version of NixOS

  12. wagnerf42 commented on Oct 2, 2021

    @wagnerf42
    Author

    hi, it does not seem easy to fix. my guess would be to fix the steam package instead by making it take into account hardware.opengl.setLdLibraryPath

    i'm getting along with LD_PRELOAD although it is not pretty

  13. stale commented on Apr 17, 2022

    @stale

    I marked this as stale due to inactivity. → More info

  14. added
    2.status: stale
    on Apr 17, 2022
  15. nixos-discourse commented on Mar 1, 2024

    @nixos-discourse
  16. removed
    2.status: stale
    on Mar 1, 2024
  17. added
    2.status: stale
    on Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug2.status: stale

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions