Step-by-step instructions for QT and KDE under Linux


WARNING --- This information is obsolete. Go here instead.

1- Introduction

This has been tested on Linux-x86 platforms with binutils >= 2.10.0.
The experimental PPC support is really experimental.

The dynamic loading speed is best measured using the LD_DEBUG=statistics option of the dynamic loader. For instance, the dynamical loading time of konqueror can be measured with the following command:

        bash$ LD_DEBUG=statistics konqueror
        26923:
        26923:  runtime linker statistics:
        26923:    total start-up time in dynamic loader: 358288994 clock cycles
        26923:              time needed for relocation: 355202059 clock cycles (99.1)
        26923:                   number of relocations: 53651
        26923:             time needed to load objects: 2864849 clock cycles (.7)

The critical number is the number of relocations which counts the number of relocations that require a symbol lookup. The time measurements are very dependent on the content of the disk buffers. The most reliable measurements are obtained by repeating the command several times and ignoring the first measurement.

2- Compile objprelink

Download the lastest source code objprelink.c. Uncompress and compile with the following command:

        $ gcc -o objprelink -O2 objprelink.c /usr/lib/libbfd.a /usr/lib/libiberty.a

Then place the binary somewhere in your path (e.g. /usr/local/bin). I suggest using the static libraries because some distributions provide a first package with the bfd shared library libbfd.so and a second package with the include files and the static libraries. These packages do not always match. Using the static libraries ensure that the include file is current with respect to the code.

Slackware 8.0 users can check Rob Kaper's post.

3- Rebuild QT

The following instructions apply to QT-2.3.1 under Linux.

Download the qt source tarball from the usual places. Patch file configs/linux-g++-shared using qt-configs.patch. Then run configure and make.

      qt-2.3.1$ patch < ../qt-configs.patch
      qt-2.3.1$ export QTDIR=`pwd`
      qt-2.3.1$ configure -shared -xft -gif -system-jpeg -system-libpng
      ......
      qt-2.3.1$ make src-moc sub-src
      ......

The shared libraries are then found in directory lib.

You can now compare the number of relocations in the installed version of qt (found in /usr/lib/qt-2.3.1/libqt.so.2.3.1 on my machine) with the new one. This can be achieved with the countreloc shell script.

          $ countreloc /usr/lib/qt-2.3.1/libqt.so.2.3.1
            16915 R_386_32
             2690 R_386_GLOB_DAT
             5040 R_386_JUMP_SLOT
             4926 R_386_RELATIVE
          $ countreloc ./lib/libqt.so.2.3.1
             4563 R_386_32
             2690 R_386_GLOB_DAT
             5039 R_386_JUMP_SLOT
            21669 R_386_RELATIVE

These numbers depend on your versions of the qt library and on the options selected when doing configure. But the order of magnitude should be correct. Then you can carefully save the installed version and replace it with the new one (danger)

        # mkdir /usr/SAVEDLIBS
        # mv  /usr/lib/qt-2.3.1/libqt.so.2.3.1  /usr/SAVEDLIBS
        # cp  ./lib/libqt.so.2.3.1  /usr/lib/qt-2.3.1/libqt.so.2.3.1
        # ldconfig

Then run some QT programs and check that everything is working properly. Complete the test by logging out from KDE and logging in again. Here is what you should see if redo the konqueror command:

        bash$ LD_DEBUG=statistics konqueror
        26927:
        26927:  runtime linker statistics:
        26927:    total startup time in dynamic loader: 292051810 clock cycles
        26927:              time needed for relocation: 288954243 clock cycles (98.9)
        26927:                   number of relocations: 41299
        26927:             time needed to load objects: 2872779 clock cycles (.9)

This is a little bit better (but not much yet).

4- Rebuild KDE

It is then time to recompile the KDE packages. The most critical ones are kdelibs and kdebase. Both can be compiled using the following procedure. You must first obtain the KDE source code from the usual places. Read carefully the KDE compilation instructions and run the following commands:

        $ make -f Makefile.cvs
        $ configure --enable-objprelink <other-relevant-options>
        $ make

The option --enable-objprelink hacks the libtool shell script. Versions of KDE older than 2.2.1 do not have this option. You should see the objprelink command run on every object files just before linking a library or an executable. You can then install the new package with the usual precautions. After recompiling kdelibs and kdebase you should obtain the following result:

        bash$ LD_DEBUG=statistics konqueror
        26891:
        26891:  runtime linker statistics:
        26891:    total startup time in dynamic loader: 171268316 clock cycles
        26891:              time needed for relocation: 168954584 clock cycles (98.6)
        26891:                   number of relocations: 21143
        26891:             time needed to load objects: 2094340 clock cycles (1.2)

The dynamic loading time has been reduced by a factor of two. It is time to focus now on konqueror's other bottlenecks.