In perl.git, the branch smoke-me/nicholas/early-Makefile-bootstrap has been 
updated

<http://perl5.git.perl.org/perl.git/commitdiff/f2bb23ac2b5cfd86691688624ec24586d3347087?hp=8a753380757ead7b856564fd8b22a477e9738cd1>

- Log -----------------------------------------------------------------
commit f2bb23ac2b5cfd86691688624ec24586d3347087
Author: Nicholas Clark <n...@ccl4.org>
Date:   Wed Jun 12 15:25:28 2013 +0200

    In miniperl, if lib/buildcustomize.pl fails to load, exit with an error.
    
    Unlike sitecustomize.pl, if lib/buildcustomize.pl exists, it should not 
fail.
    If it does, it should be reported immediately as a build failure.
    
    This makes the build process more robust.

M       perl.c

commit be0aeee89a7ae5ff40fd08feb372228f29b29cac
Author: Nicholas Clark <n...@ccl4.org>
Date:   Wed Jun 12 15:17:24 2013 +0200

    write_buildcustomize.pl now test loads the generated lib/buildcustomize.pl
    
    And deletes it if it encounters an error whilst loading it. A non-functional
    lib/buildcustomize.pl will cause the build to fail with seemingly unrelated
    errors. Deleting it and exiting with an error should make the cause of build
    failures obvious.

M       write_buildcustomize.pl

commit 6b3058844b30a9a4ae046d77364f8fded593ca10
Author: Nicholas Clark <n...@ccl4.org>
Date:   Wed Jun 12 14:42:15 2013 +0200

    write_buildcustomize.pl no longer writes to STDOUT
    
    write_buildcustomize.pl now opens lib/buildcustomize.pl itself, instead of
    writing to STDOUT and relying on the Makefile to set up redirection. This
    means that an empty lib/buildcustomize.pl is not created if
    write_buildcustomize.pl fails to compile (for whatever reason), and permits
    write_buildcustomize.pl to delete (or attempt to delete) the output file if
    it detects an error.
    
    Hard code the output file name (lib/buildcustomize.pl), as it's the same on
    all platforms, and @ARGV is already used to optionally pass a directory for
    write_buildcustomize.pl to change to before running.
    
    Experimentation suggests that various make utilities don't delete a file
    created by redirection even if an error occurs. Hence this should be more
    robust.
    
    Add -f to the miniperl commandline when running write_buildcustomize.pl to
    avoid reading in any existing lib/buildcustomize.pl. write_buildcustomize.pl
    doesn't need the setup provided by lib/buildcustomize.pl, and running it
    might cause errors which prevents writing out a correct version, making an
    incomplete build harder to recover from.

M       Makefile.SH
M       vms/descrip_mms.template
M       win32/Makefile
M       win32/makefile.mk
M       write_buildcustomize.pl

commit 24b93d3a7c36b82ebbb0fde93cdb5900a9546302
Author: Nicholas Clark <n...@ccl4.org>
Date:   Wed Jun 12 09:44:37 2013 +0200

    Remove the Icwd Makefile macros as lib/buildcustomize.pl now sets this up.
    
    Now that lib/buildcustomize.pl is built at the same time as building
    miniperl, it will always have added paths to Cwd into @INC. Hence there's no
    longer a need for Makefile macros to do this.
    
    On Win32 we can't eliminate $(ICWD) completely as it's also being used for 
some
    invocations of the (real) perl binary. Only miniperl loads buildcustomize.pl
    to set up @INC to include paths for the initial locations of modules such
    as Cwd.

M       Makefile.SH
M       vms/descrip_mms.template
M       win32/Makefile
M       win32/makefile.mk

commit 600ea516310bd64534f072b33a3e7c56d4025369
Author: Nicholas Clark <n...@ccl4.org>
Date:   Tue Jun 11 21:23:46 2013 +0200

    Generate lib/buildcustomize.pl at the same time as the miniperl executable.
    
    Doing them together ensures that we always have lib/buildcustomize.pl
    available. This simplifies things. The seemingly cranky ordering of having
    miniperl notionally depend on lib/buildcustomize.pl, and the rule for
    lib/buildcustomize.pl actually also building miniperl permits the rest of
    the Makefile to depend on (the obvious) miniperl, not the obscure
    lib/buildcustomize.pl

M       Makefile.SH
M       vms/descrip_mms.template
M       win32/Makefile
M       win32/makefile.mk
-----------------------------------------------------------------------

Summary of changes:
 Makefile.SH              |   38 +++++++++++++++++++++++---------------
 perl.c                   |    4 +++-
 vms/descrip_mms.template |   14 +++++++++-----
 win32/Makefile           |   15 ++++++++-------
 win32/makefile.mk        |   18 +++++++++---------
 write_buildcustomize.pl  |   34 +++++++++++++++++++++++++++++++++-
 6 files changed, 85 insertions(+), 38 deletions(-)

diff --git a/Makefile.SH b/Makefile.SH
index a18dff0..cac96e7 100755
--- a/Makefile.SH
+++ b/Makefile.SH
@@ -507,8 +507,6 @@ perltoc_pod_prereqs = extra.pods pod/perl5191delta.pod 
pod/perlapi.pod pod/perli
 generated_pods = pod/perltoc.pod $(perltoc_pod_prereqs)
 generated_headers = uudmap.h bitcount.h mg_data.h
 
-Icwd = -Idist/Cwd -Idist/Cwd/lib -Idist/Carp/lib
-
 lintflags = \
     -b \
     -n \
@@ -851,21 +849,32 @@ $(LIBPERL): $& $(obj) $(DYNALOADER) $(LIBPERLEXPORT)
 # build problems but that's not obvious to the novice.
 # The Module used here must not depend on Config or any extensions.
 
+# The seemingly cranky ordering of having $(MINIPERL_EXE) depend on
+# lib/buildcustomize.pl despite the reality that lib/buildcustomize.pl needs
+# miniperl to exist first permits us to
+# a) have one rule generate both miniperl and lib/buildcustomize.pl
+#    (so that lib/buildcustomise.pl is always available. This simplifies 
things)
+# b) have the rest of the Makefile depend on the more obvious $(MINIPERL_EXE)
+
+$(MINIPERL_EXE): lib/buildcustomize.pl
+
 !NO!SUBS!
 
        case "${osname}${osvers}" in
        aix*)
                $spitshell >>$Makefile <<'!NO!SUBS!'
-$(MINIPERL_EXE): $& $(mini_obj)
+lib/buildcustomize.pl: $& $(mini_obj)
        $(CC) -o $(MINIPERL_EXE) $(CLDFLAGS) $(mini_obj) $(libs)
        $(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e 
'<?>' || $(MAKE) minitest
+       $(MINIPERL) -f write_buildcustomize.pl
 !NO!SUBS!
                ;;
        next4*)
                $spitshell >>$Makefile <<'!NO!SUBS!'
-$(MINIPERL_EXE): $& $(mini_obj)
-       $(CC) -o $(MINIPERL_EXE) $(mini_obj) $(libs)
-       $(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e 
'<?>' || $(MAKE) minitest
+lib/buildcustomize.pl: $& $(mini_obj) write    ldcustomize.pl
+       $(CC) -o $(MINIPERL_EXE) $(mini_obj    libs)
+       $(LDLIBPTH) $(RUN) ./miniperl$(HOST    _EXT) -w -Ilib -MExporter -e 
'<?>' || $(MAKE) minitest
+       $(MINIPERL) -f write_buildcustomize.pl    
 !NO!SUBS!
                ;;
        darwin*)
@@ -882,27 +891,29 @@ NAMESPACEFLAGS = -force_flat_namespace
                    ;;
                esac
                $spitshell >>$Makefile <<'!NO!SUBS!'
-$(MINIPERL_EXE): $& $(mini_obj)
+lib/buildcustomize.pl: $& $(mini_obj) write_buildcustomize.pl
        -@rm -f miniperl.xok
        $(CC) $(CLDFLAGS) $(NAMESPACEFLAGS) -o $(MINIPERL_EXE) \
            $(mini_obj) $(libs)
        $(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e 
'<?>' || $(MAKE) minitest
+       $(MINIPERL) -f write_buildcustomize.pl
 !NO!SUBS!
                ;;
        *)
                $spitshell >>$Makefile <<'!NO!SUBS!'
-$(MINIPERL_EXE): $& $(mini_obj)
+lib/buildcustomize.pl: $& $(mini_obj) write_buildcustomize.pl
        -@rm -f miniperl.xok
        $(LDLIBPTH) $(CC) $(CLDFLAGS) -o $(MINIPERL_EXE) \
            $(mini_obj) $(libs)
        $(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e 
'<?>' || $(MAKE) minitest
+       $(MINIPERL) -f write_buildcustomize.pl
 !NO!SUBS!
                ;;
        esac
 
        $spitshell >>$Makefile <<'!NO!SUBS!'
 
-$(PERL_EXE): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs 
$(PERLEXPORT)
+$(PERL_EXE): $& perlmain$(OBJ_EXT) $(LIBPERL) $(static_ext) ext.libs 
$(PERLEXPORT) write_buildcustomize.pl
        -@rm -f miniperl.xok
        $(SHRPENV) $(LDLIBPTH) $(CC) -o perl$(PERL_SUFFIX) 
$(PERL_PROFILE_LDFLAGS) $(CLDFLAGS) $(CCDLFLAGS) perlmain$(OBJ_EXT) 
$(static_ext) $(LLIBPERL) `cat ext.libs` $(libs)
 
@@ -1038,7 +1049,7 @@ makeppport: \$(MINIPERL_EXE) \$(CONFIGPM)
 $spitshell >>$Makefile <<'!NO!SUBS!'
 .PHONY: makeppport
 makeppport: $(MINIPERL_EXE) $(CONFIGPM) $(nonxs_ext)
-       $(MINIPERL) $(Icwd) mkppport
+       $(MINIPERL) mkppport
 
 !NO!SUBS!
 ;;
@@ -1057,13 +1068,10 @@ $(CONFIGPOD): config.sh $(MINIPERL_EXE) configpm 
Porting/Glossary lib/Config_git
 lib/ExtUtils/Miniperl.pm: miniperlmain.c $(MINIPERL_EXE) minimod.pl $(CONFIGPM)
        $(MINIPERL) minimod.pl > lib/ExtUtils/Miniperl.pm
 
-lib/buildcustomize.pl: $(MINIPERL_EXE) write_buildcustomize.pl
-       $(MINIPERL) write_buildcustomize.pl >lib/buildcustomize.pl
-
 unidatafiles $(unidatafiles) pod/perluniprops.pod: uni.data
 
 uni.data: $(MINIPERL_EXE) $(CONFIGPM) lib/unicore/mktables $(nonxs_ext)
-       $(MINIPERL) $(Icwd) lib/unicore/mktables -C lib/unicore -P pod 
-maketest -makelist -p
+       $(MINIPERL) lib/unicore/mktables -C lib/unicore -P pod -maketest 
-makelist -p
 #      Commented out so always runs, mktables looks at far more files than we
 #      can in this makefile to decide if needs to run or not
 #      touch uni.data
@@ -1081,7 +1089,7 @@ pod/perlintern.pod: $(MINIPERL_EXE) autodoc.pl embed.fnc 
$(nonxs_ext)
        $(MINIPERL) autodoc.pl
 
 pod/perlmodlib.pod: $(MINIPERL_EXE) pod/perlmodlib.PL MANIFEST
-       $(MINIPERL) $(Icwd) pod/perlmodlib.PL -q
+       $(MINIPERL) pod/perlmodlib.PL -q
 
 pod/perl5191delta.pod: pod/perldelta.pod
        $(RMS) pod/perl5191delta.pod
diff --git a/perl.c b/perl.c
index 59fbf3c..1f8bae5 100644
--- a/perl.c
+++ b/perl.c
@@ -2090,9 +2090,11 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
        SV **const inc0 = inc ? av_fetch(inc, 0, FALSE) : NULL;
 
        if (inc0) {
+            /* if lib/buildcustomize.pl exists, it should not fail. If it does,
+               it should be reported immediately as a build failure.  */
            (void)Perl_av_create_and_unshift_one(aTHX_ &PL_preambleav,
                                                 Perl_newSVpvf(aTHX_
-                                                              "BEGIN { do 
{local $!; -f q%c%"SVf"/buildcustomize.pl%c} && do 
q%c%"SVf"/buildcustomize.pl%c }",
+        "BEGIN { do {local $!; -f q%c%"SVf"/buildcustomize.pl%c} and do 
q%c%"SVf"/buildcustomize.pl%c || die $@ }",
                                                               0, *inc0, 0,
                                                               0, *inc0, 0));
        }
diff --git a/vms/descrip_mms.template b/vms/descrip_mms.template
index bb5b00c..7ccc84b 100644
--- a/vms/descrip_mms.template
+++ b/vms/descrip_mms.template
@@ -181,7 +181,7 @@ NOOP = continue
 # Macros to invoke a copy of miniperl during the build.  Targets which
 # are built using these macros should depend on $(MINIPERL_EXE)
 MINIPERL_EXE = Sys$Disk:[]miniperl$(E)
-MINIPERL = MCR $(MINIPERL_EXE) "-I[.lib]" "-I[.dist.Cwd]" "-I[.dist.Cwd.lib]"
+MINIPERL = MCR $(MINIPERL_EXE) "-I[.lib]"
 MINIPERLQ = MCR $(MINIPERL_EXE) ""-I[.lib]""
 XSUBPP = $(MINIPERL) "-I[.ext.re]" [.lib.extutils]xsubpp -noprototypes
 # Macro to invoke a preexisting copy of Perl.  This is used to regenerate
@@ -338,16 +338,20 @@ $(PERLDELTA_CURRENT) : [.pod]perldelta.pod
 archcorefiles : $(ac) $(ARCHAUTO)time.stamp
        @ $(NOOP)
 
-[.lib]buildcustomize.pl : write_buildcustomize.pl $(MINIPERL_EXE)
-       $(MINIPERL) write_buildcustomize.pl > [.lib]buildcustomize.pl
+# See the comment in Makefile.SH explaining this seemingly cranky ordering
+$(MINIPERL_EXE) : [.lib]buildcustomize.pl
+       @ $(NOOP)
 
 vmspipe.com : [.vms]vmspipe.com
        Copy/NoConfirm/Log $(MMS$SOURCE) []
 
 miniperl : $(DBG)miniperl$(E)  vmspipe.com
        @ Continue
-$(MINIPERL_EXE) :  miniperlmain$(O), $(DBG)libperlmini$(OLB) $(CRTL)
-       Link $(LINKFLAGS)/NoDebug/Trace/NoMap/NoFull/NoCross/Exe=$(MMS$TARGET) 
miniperlmain$(O), $(DBG)libperlmini$(OLB)/Library/Include=globals $(CRTLOPTS)
+
+[.lib]buildcustomize.pl :  miniperlmain$(O), $(DBG)libperlmini$(OLB) $(CRTL) 
write_buildcustomize.pl [.lib.VMS]Filespec.pm
+       Link 
$(LINKFLAGS)/NoDebug/Trace/NoMap/NoFull/NoCross/Exe=$(MINIPERL_EXE) 
miniperlmain$(O), $(DBG)libperlmini$(OLB)/Library/Include=globals $(CRTLOPTS)
+       $(MINIPERL) "-f" write_buildcustomize.pl
+
 $(DBG)miniperl$(E) :  miniperlmain$(O), $(DBG)libperlmini$(OLB) $(CRTL)
        Link $(LINKFLAGS)/Trace/Exe=$(MMS$TARGET) miniperlmain$(O), 
$(DBG)libperlmini$(OLB)/Library/Include=globals  $(CRTLOPTS)
 
diff --git a/win32/Makefile b/win32/Makefile
index cb3f7df..8adf7f0 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -940,7 +940,7 @@ regen_config_h:
        $(MINIPERL) -I..\lib config_sh.PL $(CFG_VARS) $(CFGSH_TMPL) > 
..\config.sh
        $(MINIPERL) -I..\lib ..\configpm --chdir=..
        -del /f $(CFGH_TMPL)
-       -$(MINIPERL) -I..\lib $(ICWD) config_h.PL
+       -$(MINIPERL) -I..\lib config_h.PL
        rename config.h $(CFGH_TMPL)
 
 $(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL ..\minimod.pl
@@ -949,17 +949,18 @@ $(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL 
..\minimod.pl
        $(XCOPY) ..\*.h $(COREDIR)\*.*
        $(XCOPY) *.h $(COREDIR)\*.*
        $(RCOPY) include $(COREDIR)\*.*
-       -$(MINIPERL) -I..\lib $(ICWD) config_h.PL
+       -$(MINIPERL) -I..\lib config_h.PL
        if errorlevel 1 $(MAKE) /$(MAKEFLAGS) $(CONFIGPM)
 
-..\lib\buildcustomize.pl: $(MINIPERL) ..\write_buildcustomize.pl
-       $(MINIPERL) -I..\lib ..\write_buildcustomize.pl .. 
>..\lib\buildcustomize.pl
+# See the comment in Makefile.SH explaining this seemingly cranky ordering
+$(MINIPERL) : ..\lib\buildcustomize.pl 
 
-$(MINIPERL) : $(MINIDIR) $(MINI_OBJ)
-       $(LINK32) -subsystem:console -out:$@ @<<
+..\lib\buildcustomize.pl : $(MINIDIR) $(MINI_OBJ) ..\write_buildcustomize.pl
+       $(LINK32) -subsystem:console -out:$(MINIPERL) @<<
        $(LINK_FLAGS) $(DELAYLOAD) $(LIBFILES) $(MINI_OBJ)
 <<
        $(EMBED_EXE_MANI)
+       $(MINIPERL) -I..\lib -f ..\write_buildcustomize.pl ..
 
 $(MINIDIR) :
        if not exist "$(MINIDIR)" mkdir "$(MINIDIR)"
@@ -1075,7 +1076,7 @@ $(PERLEXESTATIC): $(PERLSTATICLIB) $(CONFIGPM) 
$(PERLEXEST_OBJ) $(PERLEXE_RES)
        $(EMBED_EXE_MANI)
 
 MakePPPort: $(MINIPERL) $(CONFIGPM) Extensions_nonxs
-       $(MINIPERL) -I..\lib $(ICWD) ..\mkppport
+       $(MINIPERL) -I..\lib ..\mkppport
 
 
#-------------------------------------------------------------------------------
 # There's no direct way to mark a dependency on
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 57373c2..4c449db 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -1070,7 +1070,7 @@ regen_config_h:
            $(CFGSH_TMPL) > ..\config.sh
        $(MINIPERL) -I..\lib ..\configpm --chdir=..
        -del /f $(CFGH_TMPL)
-       -$(MINIPERL) -I..\lib $(ICWD) config_h.PL "ARCHPREFIX=$(ARCHPREFIX)"
+       -$(MINIPERL) -I..\lib config_h.PL "ARCHPREFIX=$(ARCHPREFIX)"
        rename config.h $(CFGH_TMPL)
 
 $(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL ..\minimod.pl
@@ -1079,22 +1079,22 @@ $(CONFIGPM) : $(MINIPERL) ..\config.sh config_h.PL 
..\minimod.pl
        $(XCOPY) ..\*.h $(COREDIR)\*.*
        $(XCOPY) *.h $(COREDIR)\*.*
        $(RCOPY) include $(COREDIR)\*.*
-       $(MINIPERL) -I..\lib $(ICWD) config_h.PL "ARCHPREFIX=$(ARCHPREFIX)" \
+       $(MINIPERL) -I..\lib config_h.PL "ARCHPREFIX=$(ARCHPREFIX)" \
            || $(MAKE) $(MAKEMACROS) $(CONFIGPM) $(MAKEFILE)
 
-..\lib\buildcustomize.pl: $(MINIPERL) ..\write_buildcustomize.pl
-       $(MINIPERL) -I..\lib ..\write_buildcustomize.pl .. 
>..\lib\buildcustomize.pl
+# See the comment in Makefile.SH explaining this seemingly cranky ordering
+$(MINIPERL) : ..\lib\buildcustomize.pl
 
-
-$(MINIPERL) : $(MINIDIR) $(MINI_OBJ) $(CRTIPMLIBS)
+..\lib\buildcustomize.pl : $(MINIDIR) $(MINI_OBJ) $(CRTIPMLIBS) 
..\write_buildcustomize.pl
 .IF "$(CCTYPE)" == "GCC"
-       $(LINK32) -v -mconsole -o $@ $(BLINK_FLAGS) \
+       $(LINK32) -v -mconsole -o $(MINIPERL) $(BLINK_FLAGS) \
            $(mktmp $(LKPRE) $(MINI_OBJ) $(LIBFILES) $(LKPOST))
 .ELSE
-       $(LINK32) -subsystem:console -out:$@ $(BLINK_FLAGS) \
+       $(LINK32) -subsystem:console -out:$(MINIPERL) $(BLINK_FLAGS) \
            @$(mktmp $(DELAYLOAD) $(LIBFILES) $(MINI_OBJ))
        $(EMBED_EXE_MANI)
 .ENDIF
+       $(MINIPERL) -I..\lib -f ..\write_buildcustomize.pl ..
 
 $(MINIDIR) :
        if not exist "$(MINIDIR)" mkdir "$(MINIDIR)"
@@ -1258,7 +1258,7 @@ $(PERLEXESTATIC): $(PERLSTATICLIB) $(CONFIGPM) 
$(PERLEXEST_OBJ) $(PERLEXE_RES)
 .ENDIF
 
 MakePPPort: $(MINIPERL) $(CONFIGPM) Extensions_nonxs
-       $(MINIPERL) -I..\lib $(ICWD) ..\mkppport
+       $(MINIPERL) -I..\lib ..\mkppport
 
 
#-------------------------------------------------------------------------------
 # There's no direct way to mark a dependency on
diff --git a/write_buildcustomize.pl b/write_buildcustomize.pl
index 018e60e..92c75de 100644
--- a/write_buildcustomize.pl
+++ b/write_buildcustomize.pl
@@ -10,6 +10,8 @@ if (@ARGV) {
 unshift @INC, ('dist/Cwd', 'dist/Cwd/lib');
 require File::Spec::Functions;
 
+my $file = 'lib/buildcustomize.pl';
+
 # To clarify, this isn't the entire suite of modules considered "toolchain"
 # It's not even all modules needed to build ext/
 # It's just the source paths of the (minimum complete set of) modules in ext/
@@ -42,10 +44,15 @@ my $inc = join ",\n        ",
     map { "q\0$_\0" }
     (map {File::Spec::Functions::rel2abs($_)} @toolchain, 'lib'), '.';
 
+open my $fh, '>', $file
+    or die "Can't open $file: $!";
+
+my $error;
+
 # If any of the system's build tools are written in Perl, then this module
 # may well be loaded by a much older version than we are building. So keep it
 # as backwards compatible as is easy.
-print <<"EOT";
+print $fh <<"EOT" or $error = "Can't print to $file: $!";
 #!perl
 
 # We are miniperl, building extensions
@@ -53,3 +60,28 @@ print <<"EOT";
 # installed directories (which we don't need to read, and may confuse us)
 \@INC = ($inc);
 EOT
+
+if ($error) {
+    close $fh
+        or warn "Can't unlink $file after error: $!";
+} else {
+    if (close $fh) {
+        do $file and exit;
+        $error = "Can't load generated $file: $@";
+    } else {
+        $error = "Can't close $file: $!";
+    }
+}
+
+# It's going very wrong, so try to remove the botched file.
+
+unlink $file
+    or warn "Can't unlink $file after error: $!";
+die $error;
+
+# Local variables:
+# cperl-indent-level: 4
+# indent-tabs-mode: nil
+# End:
+#
+# ex: set ts=8 sts=4 sw=4 et:

--
Perl5 Master Repository

Reply via email to