reduce the number of unused shared libraries dependencies



Hi!

Currently most Gnome binaries and shared libraries have a lot of
unused shared library dependencies. This is not good as it increases
the startup time due to the increased number of relocations that need
to be performed. (for more information about this see Ulrich Drepper's
dsohowto.pdf document). 

An example (using garnome-2.9.91.1)
(you need a recent glibc for this, 2.3.4 works)

$ ldd -u -r ./gcalctool 
Unused direct dependencies:
        /home/dann/garnome/lib/libgnome-keyring.so.0
        /usr/lib/libjpeg.so.62
        /home/dann/garnome/lib/libbonoboui-2.so.0
        /usr/X11R6/lib/libSM.so.6
        /usr/X11R6/lib/libICE.so.6
        /usr/X11R6/lib/libX11.so.6
        /home/dann/garnome/lib/libgnomecanvas-2.so.0
        /home/dann/garnome/lib/libesd.so.0
        /home/dann/garnome/lib/libaudiofile.so.0
        /home/dann/garnome/lib/libart_lgpl_2.so.2
        /home/dann/garnome/lib/libpangoft2-1.0.so.0
        /home/dann/garnome/lib/libgdk_pixbuf-2.0.so.0
        /home/dann/garnome/lib/libpangoxft-1.0.so.0
        /home/dann/garnome/lib/libpangox-1.0.so.0
        /home/dann/garnome/lib/libpango-1.0.so.0
        /home/dann/garnome/lib/libgnomevfs-2.so.0
        /home/dann/garnome/lib/libxml2.so.2
        /lib/libssl.so.4
        /lib/libcrypto.so.4
        /usr/lib/libgssapi_krb5.so.2
        /usr/lib/libkrb5.so.3
        /lib/libcom_err.so.2
        /usr/lib/libk5crypto.so.3
        /usr/lib/libz.so.1
        /lib/libresolv.so.2
        /lib/tls/librt.so.1
        /home/dann/garnome/lib/libbonobo-2.so.0
        /home/dann/garnome/lib/libbonobo-activation.so.4
        /home/dann/garnome/lib/libORBitCosNaming-2.so.0
        /home/dann/garnome/lib/libORBit-2.so.0
        /usr/lib/libpopt.so.0
        /home/dann/garnome/lib/libgmodule-2.0.so.0
        /lib/libdl.so.2
        /home/dann/garnome/lib/libgthread-2.0.so.0
        /lib/tls/libpthread.so.0

"ld" from recent binutils (2.15?) has a new flag "--as-needed" that
can be used to avoid these unused direct dependencies. 

One quick way to test this with garnome is to change LDFLAGS in
gar.conf.mk to:
LDFLAGS += -Wl,--as-needed -L$(libdir)

The resulting Gnome binaries are 1-2K smaller. Using LD_DEBUG=statistics
to look at the runtime linker stats shows that the startup time
decreases slightly. 

Maybe it would be a good idea for garnome to add -Wl,--as-needed to
LDFLAGS by default if it can determine that the linker supports the
--as-needed flag.

            --dan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]