[Libreoffice] Get rid of unused direct dependencies

Stephan Bergmann stephan.bergmann.secondary at googlemail.com
Tue Aug 23 00:45:28 PDT 2011


On Aug 20, 2011, at 6:18 PM, Péter Rabi wrote:
> I'm interested in your opinion about the following problem of mine:
> 
> There are probably libraries and executables in LibO that are
> dynamically linked to libraries that they do not use.
> 
> I wrote some c++ code (attached) to find these needless dependencies. I
> was using `ldd -u foo' to fetch the "unused direct dependencies" of foo
> if its build is GnuMake-ified. The tool (libfilter) also removes the
> entries of these unnecessary libs from the proper makefile.
> 
> I also attached a patch containing the result I got after running
> libfilter. Unfortunately, it removed loads of libs that was
> indispensable for running foo.
> 
> I'm wondering if you could tell me why did ldd misled me (what did I
> misunderstood)?

First, you would need to use "ldd -r -u," otherwise it misses all the lazily resolved symbols (and the resulting dependencies).  Second, note that there can be various reasons for those dependencies, apart from observing they are required to resolve symbols for one specific build of LO.  (Such reasons could be differences in platform, environment, or configure switches; ABI requirements; one lib depending on .init code in another; … --- granted, some of these are more hypothetical than others…)  So, while such lists of useless dependencies are interesting, they need to be inspected more closely than to automatically remove them, I would say.  (Also see GNU ld's --as-needed.)

-Stephan


More information about the LibreOffice mailing list