[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl5-porters
Subject:    [perl #126686] [PATCH] make_ext.pl: run all Makefile.PLes in 1 process
From:       "bulk88 via RT" <perlbug-followup () perl ! org>
Date:       2015-11-30 9:14:58
Message-ID: rt-4.0.18-1730-1448874898-1166.126686-15-0 () perl ! org
[Download RAW message or body]

On Sun Nov 29 05:11:27 2015, jkeenan wrote:
> On Fri Nov 27 18:23:59 2015, bulk88 wrote:
> > On Mon Nov 23 15:46:49 2015, jkeenan wrote:
> > > Would it be possible to re-draw the patch against blead without
> > > making
> > > any whitespace changes?
> > >
> >
> 
> Thanks for the revised patch.  Unfortunately, when I applied the patch
> to a branch forked from blead at commit
> d61acc4d7a449409de2535230963f277c1c0eabb and then called, as I usually
> do, 'sh ./Configure -des -Dusedevel', 'make' failed.  Transcript of
> 'make' attached.

Revised patch attached.

-- 
bulk88 ~ bulk88 at hotmail.com

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=126686

["0001-make_ext.pl-run-all-Makefile.PLes-in-1-process.patch" (text/plain)]

From 45141c2bfafd2e18dfb00d6feb88d3f6debf8995 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Mon, 30 Nov 2015 00:50:45 -0500
Subject: [PATCH] make_ext.pl: run all Makefile.PLes in 1 process

This saves 13 wall seconds for "..\miniperl.exe -I..\lib ..\make_ext.pl
"MAKE=dmake" --dir=..\cpan --dir=..\dist --dir=..\ext --dynamic
!Unicode/Normalize" to complete on Win32. This patch catches all exit()
calls from Makefile.PLs, including exit(0) but no core modules do exit(0)
as normal flow in their Makefile.PLs. It also catches exceptions too. See
Perl RT ticket for details.
---
 make_ext.pl | 56 +++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 37 insertions(+), 19 deletions(-)

diff --git a/make_ext.pl b/make_ext.pl
index 223f67e..575239d 100644
--- a/make_ext.pl
+++ b/make_ext.pl
@@ -258,8 +258,12 @@ foreach my $spec (@extspec)  {
 		    [@pass_through, @{$extra_passthrough{$spec} || []}]);
 }
 
-sub build_extension {
-    my ($ext_dir, $perl, $mname, $target, $pass_through) = @_;
+{
+    my($del_makefile_on_exit, $ext_dir, $makefile);
+
+sub build_extension { #build_extensions is not recursion safe
+    $ext_dir = shift;
+    my ($perl, $mname, $target, $pass_through) = @_;
 
     unless (chdir "$ext_dir") {
 	warn "Cannot cd to $ext_dir: $!";
@@ -273,7 +277,7 @@ sub build_extension {
     my $return_dir = $up;
     my $lib_dir = "$up/lib";
 
-    my ($makefile, $makefile_no_minus_f);
+    my ($makefile_no_minus_f);
     if (IS_VMS) {
 	$makefile = 'descrip.mms';
 	if ($target =~ /clean$/
@@ -505,25 +509,30 @@ EOM
         # We are going to have to use Makefile.PL:
 	print "\nRunning Makefile.PL in $ext_dir\n" if $verbose;
 
-	my @args = ("-I$lib_dir", 'Makefile.PL');
-	if (IS_VMS) {
-	    my $libd = VMS::Filespec::vmspath($lib_dir);
-	    push @args, "INST_LIB=$libd", "INST_ARCHLIB=$libd";
-	} else {
-	    push @args, 'INSTALLDIRS=perl', 'INSTALLMAN1DIR=none',
-		'INSTALLMAN3DIR=none';
+	my $err;
+	{
+	    local @ARGV = (); #fake a system($^X) for perf
+	    if (IS_VMS) {
+		my $libd = VMS::Filespec::vmspath($lib_dir);
+		push @ARGV, "INST_LIB=$libd", "INST_ARCHLIB=$libd";
+	    } else {
+		push @ARGV, 'INSTALLDIRS=perl', 'INSTALLMAN1DIR=none',
+		    'INSTALLMAN3DIR=none';
+	    }
+	    push @ARGV, @$pass_through;
+	    print join(' ', @ARGV), "\n" if $verbose;
+	    local $ENV{PERL_MM_USE_DEFAULT} = 1;
+	    $del_makefile_on_exit = 1;
+	    #last statement not guarenteed to be true, see XSLoader Makefile.PL
+	    do './Makefile.PL';
+	    $del_makefile_on_exit = 0;
 	}
-	push @args, @$pass_through;
-	_quote_args(\@args) if IS_VMS;
-	print join(' ', $perl, @args), "\n" if $verbose;
-	my $code = do {
-	   local $ENV{PERL_MM_USE_DEFAULT} = 1;
-	    system $perl, @args;
-	};
-	if($code != 0){
+	if($@) {
+	    my $err = $@;
 	    #make sure next build attempt/run of make_ext.pl doesn't succeed
+	    #even though Makefile.PL failed
 	    _unlink($makefile);
-	    die "Unsuccessful Makefile.PL($ext_dir): code=$code";
+	    die "Unsuccessful Makefile.PL($ext_dir): error=$err";
 	}
 
 	# Right. The reason for this little hack is that we're sitting inside
@@ -580,6 +589,15 @@ EOS
     chdir $return_dir || die "Cannot cd to $return_dir: $!";
 }
 
+    END {
+	if($del_makefile_on_exit) { #exit() called, probably non-zero, delete
+	    #makefile so next run of make_ext.pl doesn't succeed
+	    _unlink($makefile);
+	    die "Unsuccessful Makefile.PL($ext_dir): error=exit($?) ";
+	}
+    }
+}
+
 sub _quote_args {
     my $args = shift; # must be array reference
 
-- 
1.9.5.msysgit.1



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic