autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fixes for autom4te "make -j" hack


From: Eric Sunshine
Subject: Fixes for autom4te "make -j" hack
Date: Sun, 5 Oct 2003 09:05:38 -0400

Hello,

This patch addresses a couple issues with the "make -j" hack which was  
recently added to XFile.pm to work around the flock() failure on some  
platforms.

(1) The hack assumes that MAKEFLAGS contains a verbatim copy of make's  
command-line arguments, such as "-j" or "--jobs".  Unfortunately, this is not  
the case.  Instead, MAKEFLAGS contains a specialized summary of the  
command-line arguments.  For instance, the invocation "make -e  
--ignore-errors --jobs -r" will result in MAKEFLAGS with content "rj -ie".   
The following patch addresses this issue.

(2) The hack works by ignoring flock() failure unless "make" was invoked  
with "-j" or "--jobs", in which case it the script is aborted.   
Unfortunately, for habitual users of "make -j", it might not be obvious that  
they need to drop the "-j" or run autoconf manually in order to resolve the  
issue.  The following patch augments the error message emitted by XFile.pm  
when "-j" is detected in MAKEFLAGS, and instructs the user how he might be  
able to work around the problem.  This enhanced error message should help to  
reduce the number of support requests and problem reports on the Autoconf  
mailing list.

Eric

--- autoconf/lib/Autom4te/XFile.pm      Thu Oct  2 09:25:02 2003
+++ XFile.pm-fixed      Sun Oct  5 09:01:07 2003
@@ -212,23 +212,37 @@
 ################################################
 ## Lock
 ##
+## On some systems (e.g. GNU/Linux with NFSv2, MacOS/X), flock(2) does not
+## work over NFS, but Perl prefers that over fcntl(2) if it exists and if perl
+## was not built with -Ud_flock.  Normally, this problem is harmless, so ignore
+## the ENOLCK errors that are reported in that situation.  However, if the
+## invoker is using "make -j", the problem is not harmless because concurrent
+## invocations of autom4te could corrupt the cache, thus, for this case, report
+## the problem and abort.  Note that MAKEFLAGS contains a specialized summary
+## of the options passed to make on the command-line, rather than the exact
+## options.  For example, if "make -j" or "make --jobs" is used, MAKEFLAGS will
+## be "j".  If "make --jobs=1" is used, then the "j" is ommitted entirely from
+## MAKEFLAGS (which is fine for our case).  If "make --jobs=2" is used, then
+## MAKEFLAGS might contain "j 1", "--jobserver-fds=3,4 -j", or some similar
+## incantation, depending upon the platform and version of make.  We need to
+## recognize all cases, so we check simply for "j" in MAKEFLAGS, since that
+## seems to be the lowest common denominator.  Admittedly, altering our
+## behavior based upon "make -j" is a nasty hack, but it at least handles the
+## most common case and allows the typical developer to run autom4te even on
+## platforms where flock() fails.

 sub lock
 {
   my ($fh, $mode) = @_;
-  # Cannot use @_ here.
-
-  # On some systems (e.g. GNU/Linux with NFSv2), flock(2) does not work over
-  # NFS, but Perl prefers that over fcntl(2) if it exists and if
-  # perl was not built with -Ud_flock.  Normally, this problem is harmless,
-  # so ignore the ENOLCK errors that are reported in that situation,
-  # However, if the invoker is using "make -j", the problem is not harmless,
-  # so report it in that case.  Admittedly this is a bit of a hack.
-  if (!flock ($fh, $mode)
-      && (!$!{ENOLCK} || " $ENV{'MAKEFLAGS'}" =~ / (-j|--jobs)/))
+  my $concurrent = "$ENV{'MAKEFLAGS'}" =~ /j/;
+  if (!flock ($fh, $mode) && (!$!{ENOLCK} || $concurrent))
     {
       my $file = $fh->name;
-      fatal "cannot lock $file with mode $mode: $!";
+      my $make = exists($ENV{'MAKE'}) ? $ENV{'MAKE'} : 'make';
+      my $msg = "$me: cannot lock $file with mode $mode";
+      $msg .= "; try running $me manually or run $make without the -j or " .
+        "--jobs option" if $concurrent;
+      fatal "$msg: $!";
     }
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]