From 037645b13aeb23c64d06776c679cb3d2b73a2235 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 2 Feb 2009 11:28:43 +0000 Subject: [PATCH] build system: Check for and work-around broken Perl_load_module(). Configure now checks for a broken Perl_load_module() definition as introduced in Perl 5.10 which incorrectly uses __attribute__nonnull__(3). If that has been detected, the perl plugin will now be built using -Wno-nonnull, thus ignoring the warning / error produced by the nonnull attribute. References: #41 Resolves: #42 --- configure.in | 37 +++++++++++++++++++++++++++++++++++++ src/Makefile.am | 5 +++++ 2 files changed, 42 insertions(+) diff --git a/configure.in b/configure.in index c86b7114..18a83b08 100644 --- a/configure.in +++ b/configure.in @@ -1949,6 +1949,43 @@ then CFLAGS=$SAVE_CFLAGS LDFLAGS=$SAVE_LDFLAGS fi + +if test "x$with_libperl" = "xyes" +then + SAVE_CFLAGS=$CFLAGS + SAVE_LDFLAGS=$LDFLAGS + # 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" + + AC_CACHE_CHECK([for broken Perl_load_module()], + [have_broken_perl_load_module], + AC_LINK_IFELSE( + AC_LANG_PROGRAM( + [[ +#define PERL_NO_GET_CONTEXT +#include +#include +#include + ]], + [[ + dTHX; + load_module (PERL_LOADMOD_NOIMPORT, + newSVpv ("Collectd::Plugin::FooBar", 24), + Nullsv); + ]]), + [have_broken_perl_load_module="no"], + [have_broken_perl_load_module="yes"] + ) + ) + + AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE, + test "x$have_broken_perl_load_module" = "xyes") + + CFLAGS=$SAVE_CFLAGS + LDFLAGS=$SAVE_LDFLAGS +fi # }}} # --with-libpq {{{ diff --git a/src/Makefile.am b/src/Makefile.am index 26db76db..935ed7b5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -604,6 +604,11 @@ perl_la_CPPFLAGS = $(AM_CPPFLAGS) -DHAS_BOOL=1 perl_la_CFLAGS = $(AM_CFLAGS) \ $(PERL_CFLAGS) \ -DXS_VERSION=\"$(VERSION)\" -DVERSION=\"$(VERSION)\" +# Work-around for issues #41 and #42 - Perl 5.10 incorrectly introduced +# __attribute__nonnull__(3) for Perl_load_module(). +if HAVE_BROKEN_PERL_LOAD_MODULE +perl_la_CFLAGS += -Wno-nonnull +endif perl_la_LDFLAGS = -module -avoid-version \ $(PERL_LDFLAGS) collectd_LDADD += "-dlopen" perl.la -- 2.11.0