Package: collectd Version: 4.10.1-2.1 Severity: important Tags: patch User: [email protected] Usertags: origin-ubuntu ubuntu-patch oneiric
collectd fails to build with a linker that defaults to --as-needed, as explained in this Ubuntu bug report: https://bugs.launchpad.net/ubuntu/+source/collectd/+bug/796571 http://people.canonical.com/~lamont/jamvm/logs/collectd_4.10.1-2.1ubuntu1-armel-20110612-1102 /build/collectd-SQXwoT/collectd-4.10.1/conftest.c:202: undefined reference to `Perl_Gthr_key_ptr' /build/collectd-SQXwoT/collectd-4.10.1/conftest.c:202: undefined reference to `pthread_getspecific' /build/collectd-SQXwoT/collectd-4.10.1/conftest.c:203: undefined reference to `Perl_newSVpv' /build/collectd-SQXwoT/collectd-4.10.1/conftest.c:203: undefined reference to `Perl_load_module_nocontext' This happens because ExtUtils::Embed ldopts returns linker options and libraries all mixed together, but they need to be picked apart so that the libraries can correctly come after C files / objects. For a similar case, see: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=f2481f3df4521e731da36afe7f0fe19a5c93e46d The attached patch fixes this in collectd. * libperl-linkage.dpatch: Separate Perl ldopts into components suitable for LDFLAGS and LIBS, fixing build failure with 'ld --as-needed'. Thanks, -- Colin Watson [[email protected]]
#! /bin/sh /usr/share/dpatch/dpatch-run ## libperl-linkage.dpatch by Colin Watson <[email protected]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Separate Perl ldopts into components suitable for LDFLAGS and LIBS. @DPATCH@ diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' collectd-4.10.1~/Makefile.in collectd-4.10.1/Makefile.in --- collectd-4.10.1~/Makefile.in 2010-07-09 11:02:16.000000000 +0100 +++ collectd-4.10.1/Makefile.in 2011-08-15 11:27:01.000000000 +0100 @@ -263,6 +263,7 @@ PERL_BINDINGS_OPTIONS = @PERL_BINDINGS_OPTIONS@ PERL_CFLAGS = @PERL_CFLAGS@ PERL_LDFLAGS = @PERL_LDFLAGS@ +PERL_LIBS = @PERL_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' collectd-4.10.1~/bindings/Makefile.in collectd-4.10.1/bindings/Makefile.in --- collectd-4.10.1~/bindings/Makefile.in 2010-07-09 11:02:15.000000000 +0100 +++ collectd-4.10.1/bindings/Makefile.in 2011-08-15 11:27:01.000000000 +0100 @@ -249,6 +249,7 @@ PERL_BINDINGS_OPTIONS = @PERL_BINDINGS_OPTIONS@ PERL_CFLAGS = @PERL_CFLAGS@ PERL_LDFLAGS = @PERL_LDFLAGS@ +PERL_LIBS = @PERL_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' collectd-4.10.1~/bindings/java/Makefile.in collectd-4.10.1/bindings/java/Makefile.in --- collectd-4.10.1~/bindings/java/Makefile.in 2010-07-09 11:02:15.000000000 +0100 +++ collectd-4.10.1/bindings/java/Makefile.in 2011-08-15 11:27:01.000000000 +0100 @@ -208,6 +208,7 @@ PERL_BINDINGS_OPTIONS = @PERL_BINDINGS_OPTIONS@ PERL_CFLAGS = @PERL_CFLAGS@ PERL_LDFLAGS = @PERL_LDFLAGS@ +PERL_LIBS = @PERL_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' collectd-4.10.1~/configure collectd-4.10.1/configure --- collectd-4.10.1~/configure 2011-08-15 11:27:01.000000000 +0100 +++ collectd-4.10.1/configure 2011-08-15 11:27:01.000000000 +0100 @@ -1018,6 +1018,7 @@ HAVE_BROKEN_PERL_LOAD_MODULE_TRUE BUILD_WITH_LIBPERL_FALSE BUILD_WITH_LIBPERL_TRUE +PERL_LIBS PERL_LDFLAGS PERL_CFLAGS PERL @@ -20619,10 +20620,23 @@ then SAVE_CFLAGS="$CFLAGS" SAVE_LDFLAGS="$LDFLAGS" + SAVE_LIBS="$LIBS" PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ccopts` - PERL_LDFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts` + PERL_LDFLAGS="" + PERL_LIBS="" + for ldopt in `ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`; do + case $ldopt in + -l*) + PERL_LIBS="$PERL_LIBS $ldopt" + ;; + *) + PERL_LDFLAGS="$PERL_LDFLAGS $ldopt" + ;; + esac + done CFLAGS="$CFLAGS $PERL_CFLAGS" LDFLAGS="$LDFLAGS $PERL_LDFLAGS" + LIBS="$LIBS $PERL_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libperl" >&5 $as_echo_n "checking for libperl... " >&6; } @@ -20670,12 +20684,14 @@ + else with_libperl="no" fi CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" + LIBS="$SAVE_LIBS" else if test -z "$perl_interpreter"; then with_libperl="no (no perl interpreter found)" c_cv_have_libperl="no" @@ -20693,8 +20709,10 @@ then SAVE_CFLAGS="$CFLAGS" SAVE_LDFLAGS="$LDFLAGS" + SAVE_LIBS="$LIBS" CFLAGS="$CFLAGS $PERL_CFLAGS" LDFLAGS="$LDFLAGS $PERL_LDFLAGS" + LIBS="$LIBS $PERL_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if perl supports ithreads" >&5 $as_echo_n "checking if perl supports ithreads... " >&6; } @@ -20742,16 +20760,19 @@ CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" + LIBS="$SAVE_LIBS" fi if test "x$with_libperl" = "xyes" then SAVE_CFLAGS="$CFLAGS" SAVE_LDFLAGS="$LDFLAGS" + SAVE_LIBS="$LIBS" # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3) # (see issues #41 and #42) CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror" LDFLAGS="$LDFLAGS $PERL_LDFLAGS" + LIBS="$LIBS $PERL_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken Perl_load_module()" >&5 $as_echo_n "checking for broken Perl_load_module()... " >&6; } @@ -20794,6 +20815,7 @@ CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" + LIBS="$SAVE_LIBS" fi if test "x$c_cv_have_broken_perl_load_module" = "xyes"; then HAVE_BROKEN_PERL_LOAD_MODULE_TRUE= @@ -20808,8 +20830,10 @@ then SAVE_CFLAGS="$CFLAGS" SAVE_LDFLAGS="$LDFLAGS" + SAVE_LIBS="$LIBS" CFLAGS="$CFLAGS $PERL_CFLAGS" LDFLAGS="$LDFLAGS $PERL_LDFLAGS" + LIBS="$LIBS $PERL_LIBS" ac_fn_c_check_member "$LINENO" "struct mgvtbl" "svt_local" "ac_cv_member_struct_mgvtbl_svt_local" " #include <EXTERN.h> @@ -20833,6 +20857,7 @@ CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" + LIBS="$SAVE_LIBS" fi # }}} diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' collectd-4.10.1~/configure.in collectd-4.10.1/configure.in --- collectd-4.10.1~/configure.in 2011-08-15 11:27:01.000000000 +0100 +++ collectd-4.10.1/configure.in 2011-08-15 11:27:01.000000000 +0100 @@ -2607,11 +2607,24 @@ then SAVE_CFLAGS="$CFLAGS" SAVE_LDFLAGS="$LDFLAGS" + SAVE_LIBS="$LIBS" dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string) PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ccopts` - PERL_LDFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts` + PERL_LDFLAGS="" + PERL_LIBS="" + for ldopt in `ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`; do + case $ldopt in + -l*) + PERL_LIBS="$PERL_LIBS $ldopt" + ;; + *) + PERL_LDFLAGS="$PERL_LDFLAGS $ldopt" + ;; + esac + done CFLAGS="$CFLAGS $PERL_CFLAGS" LDFLAGS="$LDFLAGS $PERL_LDFLAGS" + LIBS="$LIBS $PERL_LIBS" AC_CACHE_CHECK([for libperl], [c_cv_have_libperl], @@ -2639,12 +2652,14 @@ AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.]) AC_SUBST(PERL_CFLAGS) AC_SUBST(PERL_LDFLAGS) + AC_SUBST(PERL_LIBS) else with_libperl="no" fi CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" + LIBS="$SAVE_LIBS" else if test -z "$perl_interpreter"; then with_libperl="no (no perl interpreter found)" c_cv_have_libperl="no" @@ -2655,8 +2670,10 @@ then SAVE_CFLAGS="$CFLAGS" SAVE_LDFLAGS="$LDFLAGS" + SAVE_LIBS="$LIBS" CFLAGS="$CFLAGS $PERL_CFLAGS" LDFLAGS="$LDFLAGS $PERL_LDFLAGS" + LIBS="$LIBS $PERL_LIBS" AC_CACHE_CHECK([if perl supports ithreads], [c_cv_have_perl_ithreads], @@ -2684,16 +2701,19 @@ CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" + LIBS="$SAVE_LIBS" fi if test "x$with_libperl" = "xyes" then SAVE_CFLAGS="$CFLAGS" SAVE_LDFLAGS="$LDFLAGS" + SAVE_LIBS="$LIBS" # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3) # (see issues #41 and #42) CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror" LDFLAGS="$LDFLAGS $PERL_LDFLAGS" + LIBS="$LIBS $PERL_LIBS" AC_CACHE_CHECK([for broken Perl_load_module()], [c_cv_have_broken_perl_load_module], @@ -2718,6 +2738,7 @@ CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" + LIBS="$SAVE_LIBS" fi AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE, test "x$c_cv_have_broken_perl_load_module" = "xyes") @@ -2726,8 +2747,10 @@ then SAVE_CFLAGS="$CFLAGS" SAVE_LDFLAGS="$LDFLAGS" + SAVE_LIBS="$LIBS" CFLAGS="$CFLAGS $PERL_CFLAGS" LDFLAGS="$LDFLAGS $PERL_LDFLAGS" + LIBS="$LIBS $PERL_LIBS" AC_CHECK_MEMBER( [struct mgvtbl.svt_local], @@ -2747,6 +2770,7 @@ CFLAGS="$SAVE_CFLAGS" LDFLAGS="$SAVE_LDFLAGS" + LIBS="$SAVE_LIBS" fi # }}} diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' collectd-4.10.1~/src/Makefile.am collectd-4.10.1/src/Makefile.am --- collectd-4.10.1~/src/Makefile.am 2010-07-09 11:01:59.000000000 +0100 +++ collectd-4.10.1/src/Makefile.am 2011-08-15 11:27:01.000000000 +0100 @@ -806,6 +806,7 @@ endif perl_la_LDFLAGS = -module -avoid-version \ $(PERL_LDFLAGS) +perl_la_LIBADD = $(PERL_LIBS) collectd_LDADD += "-dlopen" perl.la collectd_DEPENDENCIES += perl.la endif diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' collectd-4.10.1~/src/Makefile.in collectd-4.10.1/src/Makefile.in --- collectd-4.10.1~/src/Makefile.in 2010-07-09 11:02:16.000000000 +0100 +++ collectd-4.10.1/src/Makefile.in 2011-08-15 11:27:01.000000000 +0100 @@ -1766,6 +1766,7 @@ PERL_BINDINGS_OPTIONS = @PERL_BINDINGS_OPTIONS@ PERL_CFLAGS = @PERL_CFLAGS@ PERL_LDFLAGS = @PERL_LDFLAGS@ +PERL_LIBS = @PERL_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ @@ -2224,6 +2225,7 @@ @BUILD_PLUGIN_PERL_TRUE@perl_la_LDFLAGS = -module -avoid-version \ @BUILD_PLUGIN_PERL_TRUE@ $(PERL_LDFLAGS) +@BUILD_PLUGIN_PERL_TRUE@perl_la_LIBADD = $(PERL_LIBS) @BUILD_PLUGIN_PINBA_TRUE@pinba_la_SOURCES = pinba.c @BUILD_PLUGIN_PINBA_TRUE@pinba_la_LDFLAGS = -module -avoid-version @BUILD_PLUGIN_PINBA_TRUE@pinba_la_LIBADD = -lprotobuf-c diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' collectd-4.10.1~/src/libcollectdclient/Makefile.in collectd-4.10.1/src/libcollectdclient/Makefile.in --- collectd-4.10.1~/src/libcollectdclient/Makefile.in 2010-07-09 11:02:16.000000000 +0100 +++ collectd-4.10.1/src/libcollectdclient/Makefile.in 2011-08-15 11:27:01.000000000 +0100 @@ -259,6 +259,7 @@ PERL_BINDINGS_OPTIONS = @PERL_BINDINGS_OPTIONS@ PERL_CFLAGS = @PERL_CFLAGS@ PERL_LDFLAGS = @PERL_LDFLAGS@ +PERL_LIBS = @PERL_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' collectd-4.10.1~/src/liboconfig/Makefile.in collectd-4.10.1/src/liboconfig/Makefile.in --- collectd-4.10.1~/src/liboconfig/Makefile.in 2010-07-09 11:02:16.000000000 +0100 +++ collectd-4.10.1/src/liboconfig/Makefile.in 2011-08-15 11:27:01.000000000 +0100 @@ -238,6 +238,7 @@ PERL_BINDINGS_OPTIONS = @PERL_BINDINGS_OPTIONS@ PERL_CFLAGS = @PERL_CFLAGS@ PERL_LDFLAGS = @PERL_LDFLAGS@ +PERL_LIBS = @PERL_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' collectd-4.10.1~/src/owniptc/Makefile.in collectd-4.10.1/src/owniptc/Makefile.in --- collectd-4.10.1~/src/owniptc/Makefile.in 2010-07-09 11:02:16.000000000 +0100 +++ collectd-4.10.1/src/owniptc/Makefile.in 2011-08-15 11:27:01.000000000 +0100 @@ -227,6 +227,7 @@ PERL_BINDINGS_OPTIONS = @PERL_BINDINGS_OPTIONS@ PERL_CFLAGS = @PERL_CFLAGS@ PERL_LDFLAGS = @PERL_LDFLAGS@ +PERL_LIBS = @PERL_LIBS@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@

