Bogus dependencies

Again, linking and symbol related. It's typical for libraries to provide foo-config scripts, or more recently pkg-config files. These are handy ways to configure a build system. Unfortunately, they have a nasty side effect - these programs produce libraries link commands like the following -L/opt/foolib/lib -lfoo -lxml2 -lglib-2.0 . The first two options are straightforward enough, but what about the last two? They are there because foolib, internally, uses libxml2 and glib2. Unfortunately it appears that some older versions of ld attempted to close the symbol set (IE ensure that every symbol involved in the program could be linked). It means that in order to link against a library, every library it used also had to linked against, and so on all the way down the dependency tree.

This is problematic. If glib or libxml was not used in your own program, your binary now has a DT_NEEDED entry for every lib involved in the link tree. If a compatible version of foolib (with the same SONAME) is available on the end users system but it was linked against a different version of a library it uses internally your binary will now break, because it has a bogus/unneeded link against it.

This issue is fixed by the latest version of apbuild, which scans binaries as they are linked for bogus dependencies, and then relinks them without the unnecessary -l options.

It is also fixed by binutils 2.15.90.0.2 and upwards if the switch --as-needed linker is specified. In the future apbuild will hopefully detect the presence of this option and use it instead of its built in dependency stripping.