diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2012-07-12 15:59:33 +0000 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2012-07-12 16:11:33 +0000 |
commit | 15f2d0318405d7646350ea0404ddc375a18b4e70 (patch) | |
tree | 8110a9ff42f53aa7604cdf2d88ba4044418a314a /Makefile.am | |
parent | aa2bb63cec3c06c2875d36731383168dbf5d1361 (diff) |
autotools: ensure that link lines are complete
As mentioned by Tino Keitel on the mailing list, some libs and
executables were only implicitly linked against libraries that they
called directly. This happened to work by chance because these libraries
ended up in the running executable anyway, due to indirect loading.
To catch such problems, the "make installcheck" was extended:
dpkg-shlibdeps is run, if available, and the error output is scanned
for the messages which indicate that a symbol is used without linking
to the right library (example output below).
Had to fix quite a few _LIBADD lines to pass the test.
Some exceptions are allowed:
- libsmltk depends on the caller providing SySync logging support.
- libneon is intentionally not linked explicitly for syncevolution.org
binaries, to make resulting binaries work with GNUTLS and OpenSSL.
dpkg-shlibdeps: warning: debian/syncevolution-libs/usr/lib/syncevolution/backends/syncdav.so contains an unresolvable reference to symbol icalparameter_new_from_value_string: it's probably a plugin.
dpkg-shlibdeps: warning: 51 other similar warnings have been skipped (use -v to see them all).
...
dpkg-shlibdeps: warning: symbol dlsym used by debian/libsyncevolution0/usr/lib/libsyncevolution.so.0.0.0 found in none of the libraries.
dpkg-shlibdeps: warning: symbol dlerror used by debian/libsyncevolution0/usr/lib/libsyncevolution.so.0.0.0 found in none of the libraries.
dpkg-shlibdeps: warning: symbol dlopen used by debian/libsyncevolution0/usr/lib/libsyncevolution.so.0.0.0 found in none of the libraries.
Diffstat (limited to 'Makefile.am')
-rw-r--r-- | Makefile.am | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 4a9b592b..e4ab8ed5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -309,6 +309,43 @@ toplevel_so_check: done endif +# Check that no executable or shared object depends on symbols in +# libraries that it does not link against. Unnecessarily linking +# against libs is okay, that can be caught and fixed by +# -Wl,--as-needed. Depends on dpkg-shlibdeps, skipped if that is +# not available. +all_local_installchecks += toplevel_link_check +toplevel_link_check: + set -x; cd $(DESTDIR) && \ + mkdir debian && \ + touch debian/control && \ + trap "rm -rf debian" EXIT && \ + files=$$(find $(DESTDIR)/$(prefix) $(DESTDIR)/$(libdir) $(DESTDIR)/$(bindir) $(DESTDIR)/$(libexecdir) -type f -perm /u+x | sort -u) && \ + files=$$(for i in $$files; do if file $$i | grep ELF >/dev/null; then echo $$i; fi; done) && \ + if ! dpkg-shlibdeps --version; then \ + echo "dpkg-shlibdeps not found, skipping link check"; \ + elif LD_LIBRARY_PATH=usr/lib:usr/lib/syncevolution dpkg-shlibdeps \ + --ignore-missing-info -O $$files \ + 2>&1 >/dev/null | \ + grep -v $(LINK_CHECK_ALLOWED) | \ + grep -e "symbol .* found in none of the libraries" \ + -e "contains an unresolvable reference to symbol" \ + ; then \ + echo "linking must be fixed"; false; \ + else \ + echo "linking is okay"; \ + fi + +# Some exceptions for the link check above (= symbol may be used without linking). +LINK_CHECK_ALLOWED = -e xxxxxxxx +# SySync_ConsolePrintf is expected by libsmltk and has to be provided by caller. +LINK_CHECK_ALLOWED += -e 'SySync_ConsolePrintf.*libsmltk.so' +if NEON_COMPATIBILITY +# libneon is intentionally not linked against, to choose between +# GNUTLS and OpenSSL at runtime. +LINK_CHECK_ALLOWED += -e 'symbol ne_.*syncdav.so' +endif + # Be strict about running 'syncevolution' only when not doing # cross-compilation: in that case, if running 'syncevolution' fails, # abort the build process. Otherwise proceed with the fallback below, |