After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 169564 - reduce the number of unused shared libraries dependencies
reduce the number of unused shared libraries dependencies
Status: RESOLVED WONTFIX
Product: GARNOME
Classification: Deprecated
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: GARNOME Maintainers
garnome list
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2005-03-08 06:43 UTC by dann
Modified: 2018-07-11 22:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
hack to add -Wl,--as-needed to LDFLAGS, iff supported (553 bytes, patch)
2005-07-07 15:17 UTC, Karsten Bräckelmann
none Details | Review
New patch for --as-needed (520 bytes, patch)
2005-10-22 21:48 UTC, Bob Kashani
none Details | Review

Description dann 2005-03-08 06:43:05 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.
Comment 1 Gad Kadosh 2005-04-09 09:22:37 UTC
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?)
Comment 2 Karsten Bräckelmann 2005-07-06 00:24:05 UTC
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.
Comment 3 dann 2005-07-06 01:08:42 UTC
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
Comment 4 Karsten Bräckelmann 2005-07-07 15:17:21 UTC
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?
Comment 5 Bob Kashani 2005-10-22 21:48:35 UTC
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.
Comment 6 Bob Kashani 2005-10-24 19:34:27 UTC
Okay, an update.

Pkgs that won't run with --as-needed:

totem
gnomemeeting
mergeant

Still requires much more testing...
Comment 7 Karsten Bräckelmann 2005-10-24 22:54:22 UTC
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.
Comment 8 Gad Kadosh 2005-10-25 00:14:14 UTC
Was it not decided that --as-needed behaviour should be done in pkgconfig ?
Comment 9 Bob Kashani 2005-10-26 02:59:51 UTC
Gad, can you clarify what you mean in comment #8? How would we go about limiting
unused direct dependencies via pkgconfig?
Comment 10 Gad Kadosh 2005-10-26 08:11:57 UTC
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.
Comment 11 André Klapper 2006-09-29 19:09:28 UTC
guys, any news/progress on this issue?
Comment 12 Joseph Sacco 2006-09-29 19:29:21 UTC
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
Comment 13 Karsten Bräckelmann 2007-04-23 21:44:17 UTC
Just committed a fix for bug 319504, so Evo finally supports --as-needed. One less to go to fix 'em all. ;)
Comment 14 André Klapper 2018-07-11 22:45:45 UTC
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