GNOME Bugzilla – Bug 169564
reduce the number of unused shared libraries dependencies
Last modified: 2018-07-11 22:45:45 UTC
Distribution/Version: Fedora Core 3 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.
I found the same thing on pretty much all my gnome binaries, but not only gnome. I'm not sure if it really increases startup times, but I did find out that when using --as-needed LDFLAGS some packages break. For example gnome-media, and more specifically gnome-cd has problems with symbols. I'm not sure if the best way to solve this issue is by using --as-needed, or by looking into pkg-config, and maybe tweaking it to behave more reasonably. (Or is there a reason to really link each binary to so many libs?)
Hmm, I'm stuck with GNU ld version 2.14.90.0.7 currently, which does not seem to support this. I'll very likely have a more recent version handy shortly... Anyway, what does this command return with an ld version that supports --as-needed? $ ld --help | grep as-needed Depending on this output I think I can come up with a hack to automatically detect and use this feature.
ld --help | grep as-needed --as-needed Only set DT_NEEDED for following dynamic libs if used --no-as-needed Always set DT_NEEDED for following dynamic libs
Created attachment 48784 [details] [review] hack to add -Wl,--as-needed to LDFLAGS, iff supported I'm by no means an ld expert, so please check the options added carefully. Does adding -Wl,--as-needed work reliably? Or does it break the build in some cases? This patch prepends LDFLAGS with -Wl,--as-needed, iff 'ld' supports it. The redirection of STDERR is to prevent any error messages an 'ld' returns, if the --help option is unknown (this is the case for "Solaris Link Editors: 5.8-1.295" by a quick test). Does this patch fix this enhancement request?
Created attachment 53775 [details] [review] New patch for --as-needed The --as-needed option seems to speed things. I'm still doing some testing to see how much of an improvement it makes now. But it looks worth while to add.
Okay, an update. Pkgs that won't run with --as-needed: totem gnomemeeting mergeant Still requires much more testing...
Bob, as you're doing a lot of testing (thanks :) and started keeping track of apps that need special treatment (read: possibly remove that LDFLAG), here's another update. As you've found out, evolution 2.4.1 doesn't even pass configure with --as-needed. My hack for this in bug #319504 is fine with the evolution team and should be in in the next evolution release.
Was it not decided that --as-needed behaviour should be done in pkgconfig ?
Gad, can you clarify what you mean in comment #8? How would we go about limiting unused direct dependencies via pkgconfig?
I don't remember exactly, but at some point there was a change in pkg-config to make it handle lib dependencies more efficiently, linking against less unneeded deps. I might be totally confused about this though.
guys, any news/progress on this issue?
Short answer: no... The ability to reduce the number of unused shared libraries for an application is compiler/linker dependent. GARNOME services N different distros with Pn different versions. We cannot force people to update their compilers, linkers, and C libraries. Major obsolescence is the only mechanism known to incent some people to upgrade. -Joseph
Just committed a fix for bug 319504, so Evo finally supports --as-needed. One less to go to fix 'em all. ;)
GARNOME has not seen any code changes since 2008: https://git.gnome.org/browse/archive/garnome/log This project is not under active development anymore and got archived in Git. It is currently unlikely that there will be any further active development. Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect reality. Please feel free to reopen this bug report in the future if anyone takes the responsibility for active development again. If you are interested in maintainership, inform https://mail.gnome.org/mailman/listinfo/desktop-devel-list