PDA

View Full Version : switching drivers for development



Brandon J. Van Every
08-20-2012, 05:08 AM
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.

thokra
08-20-2012, 07:03 AM
That depends obn which driver you're talking about.

marshats
08-20-2012, 06:07 PM
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

Brandon J. Van Every
08-21-2012, 12:27 AM
That library trick is interesting, but I want to substitute entire NVIDIA proprietary drivers.

thokra
08-21-2012, 01:33 AM
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?

marshats
08-21-2012, 07:32 AM
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.

Dark Photon
08-21-2012, 05:17 PM
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


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

Brandon J. Van Every
08-24-2012, 07:12 AM
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?

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.