Switching drivers for development

My Linux kung fu is rusty. Is there a safe, semi-convenient way to switch back and forth between a production and a beta driver? I don’t want to clobber my production system with a beta driver. Last time I did that, I ended up losing the system and had to spend a few days reinstalling. I don’t really want to have to reboot into a completely separate system all the time either. I’m thinking, something like an installation with multiple X servers or something like that? Then I could use all the same kernel, apps, libs, paths, etc. and it’s just the X server that changes.

That depends obn which driver you’re talking about.

Do you want to substitute a particular library? LD_PRELOAD can be used for that purpose as follows. Say you have libraries in fullpath1 and fullpath2 each with different library versions and your executable requires libraries -lFOO and -lBAR. To link at runtime and use library set “1”


LD_PRELOAD="<fullpath1>/libFOO.so <fullpath1>/libBAR.so" ./your_executable

Similarly, to link at runtime and use library set “2”


LD_PRELOAD="<fullpath2>/libFOO.so <fullpath2>/libBAR.so" ./your_executable

That library trick is interesting, but I want to substitute entire NVIDIA proprietary drivers.

Normally, there shouldn’t be any problem with a new NVIDIA blob - it’s mostly the other way around, i.e. if you upgrade to a newer X.Org version and the blob doesn’t support the new ABI (which happens with almost every new X.Org release). It may also occur that some packages are dependent on stable, pre-packaged repository versions of the drivers (like Ubuntu’s nvidia-current) so when removing these you’ll also have to struggle with unfulfilled dependencies. What distro are you using?

I use the LD_PRELOAD to substitute temporarily from commandline the mesa3D for nvidia drivers as follows


Mesa-8.0.4$ LD_PRELOAD="lib/gallium/libGL.so lib/libGLU.so" ldd my_executable 

ldd shows that the relative path ie mesa3d opengl libraries are used


        lib/gallium/libGL.so (0x00007fc051bf4000)
        lib/libGLU.so (0x00007fc051981000)

in contrast without using LD_PRELOAD the default system library is used (in my case that is the nvidia driver)


ldd my_executable

        libGL.so.1 => /usr/lib/nvidia-current/libGL.so.1 (0x00007f8c6f15c000)
        libnvidia-tls.so.295.40 => /usr/lib/nvidia-current/tls/libnvidia-tls.so.295.40 (0x00007f8c6d725000)
        libnvidia-glcore.so.295.40 => /usr/lib/nvidia-current/libnvidia-glcore.so.295.40 (0x00007f8c6b400000)

ps once satisfied that the library is as expected just remove ldd so your_executable will run with the library you chose.

[QUOTE=marshats;1241663]I use the LD_PRELOAD to substitute temporarily from commandline the mesa3D for nvidia drivers as follows


Mesa-8.0.4$ LD_PRELOAD="lib/gallium/libGL.so lib/libGLU.so" ldd my_executable 

[/quote]

FWIW, to make this work with any shell, not just sh-style shells, prefix with “env”:

env LD_PRELOAD="lib/gallium/libGL.so lib/libGLU.so" ldd my_executable

Well, the point is I don’t want to deal with whether uninstalling / reinstalling drivers “just works” or not. I don’t want to do that at all, as last time around it did not “just work”. I want to keep several installations in parallel and switch between them. Maybe hoping that the packages won’t clobber each other is unrealistic. I’m using Lubuntu 12.04.

I will investigate the LD_PRELOAD trick to the extent I can make use of it.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.