Subject: Please review: perl patch to make more painless
To: None <>
From: Johnny Lam <>
List: tech-pkg
Date: 10/01/2001 10:57:14
I've included below a patch to the perl package that causes perl modules
from CPAN to link directly against -lperl when built.  Combined with the
recent update of perl to add ${LOCALBASE}/lib to the rpath when creating
shared libraries/modules, these two changes make using (ap-perl)
more painless.  Instead of needing:

	LoadFile !/usr/lib/
	LoadFile lib/perl5/5.6.1/i386-netbsd/CORE/
	# Any other libraries needed by perl shared modules need to listed
	# with LoadFile here.
	LoadModule perl_module lib/httpd/
	AddModule mod_perl.c

you'd need only the last two lines as the mod_perl authors intended.

I've tested this patch for several weeks now, and I haven't noticed any
problems with normal perl usage.  However, I admit that I'm a light perl
user at best, so it's not tested thoroughly at all.

I'd like for others to test this patch, or at least view it and tell me
of any potential problems with the patch, or with the whole idea or linking
perl modules against  To test this, please save this patch as
lang/perl5/patches/patch-af and recompile perl.  If I don't hear any
problems over the next two weeks, I'm going to commit this to the tree.


	-- Johnny Lam <>


--- lib/ExtUtils/	Thu Mar 15 10:25:20 2001
+++ lib/ExtUtils/	Mon Oct  1 03:51:12 2001
@@ -1059,6 +1059,22 @@
     my($ldfrom) = '$(LDFROM)';
     $armaybe = 'ar' if ($^O eq 'dec_osf' and $armaybe eq ':');
+    # Set LLIBPERL to nothing on static perl platforms, and to the flags
+    # needed to link against the shared libperl library on shared perl
+    # platforms.  We peek at lddlflags to see if we need -Wl,-R or -R
+    # to add paths to the run-time library search path.
+    #
+    my($llibperl) = '';
+    if (($^O eq 'netbsd') and ($Config{'useshrplib'} eq 'true')) {
+	if ($Config{'lddlflags'} =~ /-Wl,-R/) {
+	    $llibperl = '-L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -lperl';
+	} elsif ($Config{'lddlflags'} =~ /-R/) {
+	    $llibperl = '-L$(PERL_INC) -R$(INSTALLARCHLIB)/CORE -lperl';
+	}
+    }
+    push(@m,'LLIBPERL = '.$llibperl."\n");
 # This section creates the dynamically loadable $(INST_DYNAMIC)
 # from $(OBJECT) and possibly $(MYEXTLIB).
@@ -1088,7 +1104,7 @@
     push(@m,'	LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) '.$ldrun.' $(LDDLFLAGS) '.$ldfrom.
     push @m, '
 	$(CHMOD) $(PERM_RWX) $@