Subject: Re: pkg/13726: problems w/ perl, mod_perl, and C based perl modules?
To: None <tech-pkg@netbsd.org>
From: Johnny Lam <jlam@c35.jgrind.org>
List: tech-pkg
Date: 09/22/2001 21:03:51
I'm trying to solve pkg/13726 where using perl modules within Apache with
mod_perl.so leads to errors with not finding symbols in libperl.so. On
NetBSD-1.5Y/I386 (ELF), the link command used to create mod_perl.so is:
ld --whole-archive -shared -L/usr/pkg/lib
-o mod_perl.so
mod_perl.lo perlxsi.lo perl_config.lo perl_util.lo perlio.lo
mod_perl_opmask.lo Apache.lo Constants.lo ModuleConfig.lo Log.lo
URI.lo Util.lo Connection.lo Server.lo File.lo Table.lo
/usr/pkg/lib/perl5/5.6.1/i386-netbsd/DynaLoader_pic.o
-whole-archive -lgcc -no-whole-archive -E
-R/usr/pkg/lib -R/usr/pkg/lib/perl5/5.6.1/i386-netbsd/CORE
-L/usr/pkg/lib -L/usr/pkg/lib/perl5/5.6.1/i386-netbsd/CORE
-lperl -lm -lcrypt
As you can see, libperl.so is linked into mod_perl.so and the proper
locations are added to mod_perl.so's rpath, and -E (-export-dynamic).
The PR fix is to link perl modules against libperl.so, which is reported
to solve the problem. The patch included below causes all of the pkgsrc
p5-* modules to automatically link against -lperl. It should be saved
as lang/perl5/patches/patch-af.
Can anyone confirm that this fixes things? My knowledge of perl is scant,
and the PR didn't have a test case I could use. Can anyone see if this
might break normal perl module usage outside of mod_perl.so?
Thanks,
-- Johnny Lam <jlam@jgrind.org>
--- lib/ExtUtils/MM_Unix.pm.orig Thu Mar 15 07:25:20 2001
+++ lib/ExtUtils/MM_Unix.pm Sun Sep 2 16:09:07 2001
@@ -1059,6 +1059,9 @@
my($ldfrom) = '$(LDFROM)';
$armaybe = 'ar' if ($^O eq 'dec_osf' and $armaybe eq ':');
my(@m);
+ my($llibperl) = '';
+ $llibperl = '-L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -lperl' if ($^O eq 'netbsd');
+ push(@m,'LLIBPERL = '.$llibperl."\n");
push(@m,'
# This section creates the dynamically loadable $(INST_DYNAMIC)
# from $(OBJECT) and possibly $(MYEXTLIB).
@@ -1088,7 +1091,7 @@
');
push(@m,' LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) '.$ldrun.' $(LDDLFLAGS) '.$ldfrom.
- ' $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST)');
+ ' $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) $(PERL_ARCHIVE) $(LLIBPERL) $(LDLOADLIBS) $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST)');
push @m, '
$(CHMOD) $(PERM_RWX) $@
';