From: Timo Sirainen Date: Mon, 8 Aug 2016 10:12:15 +0000 (+0300) Subject: Moved cc-wrapper.sh handling to dovecot.m4 X-Git-Tag: 2.2.27~333 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7adf84cd0ed9bfaf0d1f4cce6111b3cb4e1943d6;p=thirdparty%2Fdovecot%2Fcore.git Moved cc-wrapper.sh handling to dovecot.m4 When configuring Dovecot --without-shared-libs and pointing external plugins to uninstalled sources --with-dovecot, any binaries complied for plugins weren't using cc-wrapper.sh, which could have caused runtime failures when they attempted to load plugins dynamically. Now it's possible to add DC_CC_WRAPPER to plugins' configure.ac to build with the cc-wrapper.sh. --- diff --git a/Makefile.am b/Makefile.am index e3145a8e7f..f484aa2153 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,7 +13,6 @@ EXTRA_DIST = \ COPYING.LGPL \ COPYING.MIT \ ChangeLog \ - cc-wrapper.sh.in \ update-version.sh \ run-test-valgrind.supp \ $(conf_DATA) diff --git a/cc-wrapper.sh.in b/cc-wrapper.sh.in deleted file mode 100644 index 9a301c7fbd..0000000000 --- a/cc-wrapper.sh.in +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -if echo "$*" | grep -- -ldl > /dev/null; then - # the binary uses plugins. make sure we include everything from .a libs - exec @CC@ -Wl,--whole-archive $* -Wl,--no-whole-archive -else - exec @CC@ $* -fi diff --git a/configure.ac b/configure.ac index e9ea339d18..7aa9af9ab7 100644 --- a/configure.ac +++ b/configure.ac @@ -2860,14 +2860,7 @@ fi LDFLAGS="\$(NOPLUGIN_LDFLAGS) $LDFLAGS" AC_SUBST(NOPLUGIN_LDFLAGS) -if test "$with_gnu_ld" = yes -a "$want_shared_libs" = "no"; then - # libtool can't handle using whole-archive flags, so we need to do this - # with a CC wrapper.. shouldn't be much of a problem, since most people - # are building with shared libs. - sed "s:@CC@:$CC:" < $srcdir/cc-wrapper.sh.in > cc-wrapper.sh - chmod +x cc-wrapper.sh - CC=`pwd`/cc-wrapper.sh -fi +DC_CC_WRAPPER if test "$docdir" = ""; then dnl docdir supported only by autoconf v2.59c and later diff --git a/dovecot.m4 b/dovecot.m4 index 4fca0a0af6..b77a915b09 100644 --- a/dovecot.m4 +++ b/dovecot.m4 @@ -6,7 +6,7 @@ # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. -# serial 23 +# serial 24 AC_DEFUN([DC_DOVECOT_MODULEDIR],[ AC_ARG_WITH(moduledir, @@ -137,3 +137,28 @@ AC_DEFUN([DC_DOVECOT],[ DC_PLUGIN_DEPS DC_DOVECOT_TEST_WRAPPER ]) + +AC_DEFUN([DC_CC_WRAPPER],[ + if test "$want_shared_libs" != "yes"; then + # want_shared_libs=no is for internal use. the liblib.la check is for plugins + if test "$want_shared_libs" = "no" || echo "$LIBDOVECOT" | grep "/liblib.la" > /dev/null; then + if test "$with_gnu_ld" = yes; then + # libtool can't handle using whole-archive flags, so we need to do this + # with a CC wrapper.. shouldn't be much of a problem, since most people + # are building with shared libs. + cat > cc-wrapper.sh < /dev/null; then + # the binary uses plugins. make sure we include everything from .a libs + exec $CC -Wl,--whole-archive \$[*] -Wl,--no-whole-archive +else + exec $CC \$[*] +fi +EOF + chmod +x cc-wrapper.sh + CC=`pwd`/cc-wrapper.sh + fi + fi + fi +])