Package: libapache2-mod-perl2
Version: 2.0.8+httpd24-r1449661-8
Severity: important
Tags: patch
This package fails to build with DEB_BUILD_OPTIONS=noopt (gcc -O0)
because t/apr-ext tests fail:
t/api/uri.t ............................. ok
Can't load
'/tmp/buildd/libapache2-mod-perl2-2.0.8+httpd24-r1449661/blib/arch/auto/APR/APR.so'
for module APR:
/tmp/buildd/libapache2-mod-perl2-2.0.8+httpd24-r1449661/blib/arch/auto/APR/APR.so:
undefined symbol: perl_module at /usr/lib/perl/5.18/DynaLoader.pm line 184.
at
/tmp/buildd/libapache2-mod-perl2-2.0.8+httpd24-r1449661/blib/lib/APR/Base64.pm
line 23.
Compilation failed in require at
/tmp/buildd/libapache2-mod-perl2-2.0.8+httpd24-r1449661/blib/lib/APR/Base64.pm
line 23.
[...]
t/apr-ext/base64.t ......................
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
[...]
Summary Report
-------------------
t/apr-ext/base64.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: No plan found in TAP output
t/apr-ext/brigade.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: No plan found in TAP output
t/apr-ext/bucket.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: No plan found in TAP output
[...]
Files=248, Tests=2237, 202 wallclock secs ( 1.19 usr 0.40 sys + 117.75 cusr
17.60 csys = 136.94 CPU)
Result: FAIL
Failed 14/248 test programs. 0/2237 subtests failed.
This missing 'perl_module' symbol is mod_perl itself, so this means
APR.so can only be loaded from inside mod_perl:
% perl -Iblib/lib -Iblib/arch -MAPR -e1
Can't load 'blib/arch/auto/APR/APR.so' for module APR:
blib/arch/auto/APR/APR.so: undefined symbol: perl_module at
/usr/lib/perl/5.18/DynaLoader.pm line 184.
at -e line 0.
Compilation failed in require.
BEGIN failed--compilation aborted.
The problem comes from src/modules/perl/modperl_apache_includes.h:
#if !defined(MP_IN_XS) && AP_MODULE_MAGIC_AT_LEAST(20100606, 0)
APLOG_USE_MODULE(perl);
#endif
where APLOG_USE_MODULE(perl) expands via /usr/include/apache2/http_config.h to
extern module perl_module; static int * const aplog_module_index =
&(perl_module.module_index);
At -O2, this is optimized away when it's not used, but -O0 keeps it.
Defining MP_IN_XS for the APR (and APR/PerlIO) build seems to help.
I was able to get the test suite pass at both -O0 and -O2 with the
attached patch.
It seems possible that other parts of xs/ are affected too but aren't
exercised by the test suite.
The history of MP_IN_XS is just
http://svn.apache.org/viewvc?view=revision&revision=1410295
http://svn.apache.org/viewvc?view=revision&revision=68792
but it does look like the correct solution, one way or another.
--
Niko Tyni [email protected]
>From 18be0d0e46958e9c935c01e5eee30dbae8880e30 Mon Sep 17 00:00:00 2001
From: Niko Tyni <[email protected]>
Date: Mon, 4 Aug 2014 10:32:36 +0300
Subject: [PATCH] Define MP_IN_XS to avoid referencing &perl_module outside of
mod_perl
APLOG_USE_MODULE(perl) expands to
extern module perl_module; static int * const aplog_module_index = &(perl_module.module_index);
which makes loading APR.so impossible outside mod_perl unless
aplog_module_index is optimized away by the compiler.
This causes mod_perl test suite failures in t/apr-ext at "gcc -O0".
See also
http://svn.apache.org/viewvc?view=revision&revision=68792
http://svn.apache.org/viewvc?view=revision&revision=1410295
---
xs/APR/APR/Makefile.PL | 7 +++++++
xs/APR/PerlIO/Makefile.PL | 3 +++
2 files changed, 10 insertions(+)
diff --git a/xs/APR/APR/Makefile.PL b/xs/APR/APR/Makefile.PL
index 79a0a0e..327dac3 100644
--- a/xs/APR/APR/Makefile.PL
+++ b/xs/APR/APR/Makefile.PL
@@ -25,6 +25,13 @@ $libs = delete $args{LIBS} if $args{LIBS};
my $build = ModPerl::BuildMM::build_config();
+my $ccopts = $build->ccopts;
+
+# avoid referencing &perl_module outside of mod_perl
+$ccopts .= ' -DMP_IN_XS';
+
+$args{CCFLAGS} = $ccopts;
+
my @apru_link_flags = $build->apru_link_flags;
$libs .= join ' ', @apru_link_flags if @apru_link_flags;
diff --git a/xs/APR/PerlIO/Makefile.PL b/xs/APR/PerlIO/Makefile.PL
index 4a8f60d..ca102bb 100644
--- a/xs/APR/PerlIO/Makefile.PL
+++ b/xs/APR/PerlIO/Makefile.PL
@@ -25,6 +25,9 @@ if ($build->has_large_files_conflict) {
: '';
}
+# avoid referencing &perl_module outside of mod_perl
+$ccopts .= ' -DMP_IN_XS';
+
ModPerl::BuildMM::WriteMakefile(
NAME => 'APR::PerlIO',
VERSION_FROM => 'PerlIO.pm',
--
2.0.1