gozer 2004/09/21 14:35:30
Modified: . Changes
lib/ModPerl Code.pm WrapXS.pm
src/modules/perl .cvsignore mod_perl.c
Log:
Generate modperl_exports.c for static builds to prevent the
linker from stripping needed but unused symbols
Revision Changes Path
1.494 +3 -0 modperl-2.0/Changes
Index: Changes
===================================================================
RCS file: /home/cvs/modperl-2.0/Changes,v
retrieving revision 1.493
retrieving revision 1.494
diff -u -r1.493 -r1.494
--- Changes 21 Sep 2004 07:46:22 -0000 1.493
+++ Changes 21 Sep 2004 21:35:29 -0000 1.494
@@ -12,6 +12,9 @@
=item 1.99_17-dev
+Generate modperl_exports.c for static builds to prevent the
+linker from stripping needed but unused symbols [Gozer]
+
Add .libs/ as part of the library search path when building
against httpd's source tree [Gozer]
1.126 +8 -1 modperl-2.0/lib/ModPerl/Code.pm
Index: Code.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/ModPerl/Code.pm,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -r1.125 -r1.126
--- Code.pm 2 Jul 2004 19:04:32 -0000 1.125
+++ Code.pm 21 Sep 2004 21:35:30 -0000 1.126
@@ -637,6 +637,7 @@
generate_largefiles => {h => 'modperl_largefiles.h'},
generate_constants => {h => 'modperl_constants.h',
c => 'modperl_constants.c'},
+ generate_exports => {c => 'modperl_exports.c'},
);
my @c_src_names = qw(interp tipool log config cmd options callback handler
@@ -645,7 +646,7 @@
const constants apache_compat error debug
common_util common_log);
my @h_src_names = qw(perl_unembed);
-my @g_c_names = map { "modperl_$_" } qw(hooks directives flags xsinit);
+my @g_c_names = map { "modperl_$_" } qw(hooks directives flags xsinit exports);
my @c_names = ('mod_perl', (map "modperl_$_", @c_src_names));
sub c_files { [map { "$_.c" } @c_names, @g_c_names] }
sub o_files { [map { "$_.o" } @c_names, @g_c_names] }
@@ -1083,6 +1084,12 @@
unless $seen_const{$class}{$name}
}
}
+}
+
+sub generate_exports {
+ my($self, $c_fh) = @_;
+ require ModPerl::WrapXS;
+ ModPerl::WrapXS->generate_exports($c_fh);
}
# src/modules/perl/*.c files needed to build APR/APR::* outside
1.80 +30 -0 modperl-2.0/lib/ModPerl/WrapXS.pm
Index: WrapXS.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/ModPerl/WrapXS.pm,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- WrapXS.pm 21 Sep 2004 05:54:56 -0000 1.79
+++ WrapXS.pm 21 Sep 2004 21:35:30 -0000 1.80
@@ -1267,5 +1267,35 @@
return \%stats;
}
+sub generate_exports {
+ my($self, $fh) = @_;
+
+ if (!$build->should_build_apache) {
+ print $fh <<"EOF";
+/* This is intentionnaly left blank, only usefull for static build */
+const void *modperl_ugly_hack = NULL;
+EOF
+ return;
+ }
+
+ print $fh <<"EOF";
+/*
+ * This is indeed a ugly hack!
+ * See also src/modules/perl/mod_perl.c for modperl_ugly_hack
+ * If we don't build such a list of exported API functions, the over-zealous
+ * linker can and will remove the unused functions completely. In order to
+ * avoid this, we create this object and modperl_ugly_hack to create a
+ * dependency between all the exported API and mod_perl.c
+ */
+const void *modperl_ugly_hack = NULL;
+EOF
+
+ for my $entry (@$ModPerl::FunctionTable) {
+ next if $self->func_is_static($entry);
+ ( my $name ) = $entry->{name} =~ /^modperl_(.*)/;
+ print $fh "const void *modperl_hack_$name = (const void *)modperl_$name;\n";
+ }
+}
+
1;
__END__
1.13 +1 -0 modperl-2.0/src/modules/perl/.cvsignore
Index: .cvsignore
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/.cvsignore,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- .cvsignore 11 Sep 2004 00:07:33 -0000 1.12
+++ .cvsignore 21 Sep 2004 21:35:30 -0000 1.13
@@ -1,3 +1,4 @@
+modperl_exports.c
modperl_hooks.h
modperl_hooks.c
modperl_flags.h
1.222 +11 -0 modperl-2.0/src/modules/perl/mod_perl.c
Index: mod_perl.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
retrieving revision 1.221
retrieving revision 1.222
diff -u -r1.221 -r1.222
--- mod_perl.c 18 Sep 2004 04:33:34 -0000 1.221
+++ mod_perl.c 21 Sep 2004 21:35:30 -0000 1.222
@@ -1034,6 +1034,17 @@
return retval;
}
+/* This ugly hack pulls in any function listed in
+ * modperl_exports.c. Otherwise, the over-zealous
+ * linker would remove unused api functions
+ */
+const void *modperl_suck_in_ugly_hack(void);
+const void *modperl_suck_in_ugly_hack(void)
+{
+ extern const void *modperl_ugly_hack;
+ return modperl_ugly_hack;
+}
+
module AP_MODULE_DECLARE_DATA perl_module = {
STANDARD20_MODULE_STUFF,
modperl_config_dir_create, /* dir config creater */