Prelink and libGL.so : a tip

Leon Bottou leon at bottou.org
Sat Nov 29 03:18:54 CET 2003


It is often quite difficult to use prelink with KDE
because QT depends on libGL.so and libGL.so
is often compiled as a non-PIC library for
performance reasons. 

The NVidia libraries are compiled this way,
and I cannot recompile them in PIC mode
for lack of source.  Sigh.

This is frustrating because 95% of the KDE executables do not need libGL.
Why not make QT load libGL when it needs it only?

The attached patch does this.
It creates little stubs for all the openGL functions needed by QT.  
libGL.so is loaded with dlopen the first time one of these stubs 
is called. Otherwise the stub simply calls the required function.

Rough recipe:
- Get the qt-3.1.2 package for your distribution.
- Apply the distribution specific patches  (e.g. redhat9 has a lot of them...)
- Apply the attached patch.
- Run the script 'configure' that comes with Qt with the appropriate options.
- Edit the file src/Makefile to remove -lGL from the command for linking qt.so.
- Make.

I did it on my redhat9 box by loading the fedora source rpm  (qt-3.1.2-7.fdr.3.src.rpm)
and modifying the spec file to apply the pactch and tweak the makefile.

Result:

[leonb at humbert SPECS]$ LD_DEBUG=statistics konqueror
     25895:
     25895:     runtime linker statistics:
     25895:       total startup time in dynamic loader: 7824120 clock cycles
     25895:                 time needed for relocation: 2653360 clock cycles (33.9%)
     25895:                      number of relocations: 0
     25895:           number of relocations from cache: 1940
     25895:                time needed to load objects: 4555144 clock cycles (58.2%)




P.S. -- 
I am talking about Jakub Jelinek's ELF prelinker, 
not about my old objprelink hack.  It does
not work with gcc-3 anyway.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt-x11-free-3.1.2-glstubs.patch
Type: text/x-diff
Size: 10503 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-optimize/attachments/20031128/888dc826/qt-x11-free-3.1.2-glstubs.bin


More information about the Kde-optimize mailing list