automake-patches
[Top][All Lists]
Advanced

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

FYI: use mkdir -p only with GNU mkdir :(


From: Alexandre Duret-Lutz
Subject: FYI: use mkdir -p only with GNU mkdir :(
Date: Sun, 15 Feb 2004 22:14:03 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

I'm installing this on branch-1-8 and HEAD.

2004-02-15  Alexandre Duret-Lutz  <address@hidden>

        * m4/mkdirp.m4: Use `mkdir -p' only with GNU mkdir, because
        Solaris 8's mkdir is not thread safe.
        * lib/mkinstalldirs: Likewise.
        * lib/install-sh: Abort when mkdir fails to create a directory.
        Report from Nathanael Nerode.

Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.256.2.27
diff -u -r1.256.2.27 NEWS
--- NEWS        7 Feb 2004 13:46:02 -0000       1.256.2.27
+++ NEWS        15 Feb 2004 20:59:19 -0000
@@ -23,6 +23,14 @@
   - Do not assume that users override _DEPENDENCIES in all conditions
     where Automake will try to define them.
 
+  - Do not use `mkdir -p' in mkinstalldirs, unless this is GNU mkdir.
+    Solaris 8's `mkdir -p' is not thread-safe and can break parallel
+    builds.
+
+    This fix also affects the $(mkdir_p) variable defined since
+    Automake 1.8.  It will be set to `mkdir -p' only if mkdir is GNU
+    mkdir, and to `mkinstalldirs' or `install-sh -d' otherwise.
+
 * Bugs introduced by 1.8:
 
   - In some situations (hand-written `m4_include's), aclocal would
Index: THANKS
===================================================================
RCS file: /cvs/automake/automake/THANKS,v
retrieving revision 1.230.2.10
diff -u -r1.230.2.10 THANKS
--- THANKS      7 Feb 2004 13:46:02 -0000       1.230.2.10
+++ THANKS      15 Feb 2004 20:59:19 -0000
@@ -161,6 +161,7 @@
 Mirko Streckenbach     address@hidden
 Morten Eriksen         address@hidden
 Motoyuki Kasahara      address@hidden
+Nathanael Nerode       address@hidden
 Nelson H. F. Beebe     address@hidden
 Nicholas Wourms                address@hidden
 Nicolas Joly           address@hidden
Index: lib/install-sh
===================================================================
RCS file: /cvs/automake/automake/lib/install-sh,v
retrieving revision 1.13.2.2
diff -u -r1.13.2.2 install-sh
--- lib/install-sh      12 Jan 2004 09:51:38 -0000      1.13.2.2
+++ lib/install-sh      15 Feb 2004 20:59:22 -0000
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2004-01-12.10
+scriptversion=2004-02-15.20
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -228,7 +228,13 @@
     while test $# -ne 0 ; do
       pathcomp=$pathcomp$1
       shift
-      test -d "$pathcomp" || $mkdirprog "$pathcomp"
+      if test ! -d "$pathcomp"; then
+        $mkdirprog "$pathcomp" || lasterr=$?
+       # mkdir can fail with a `File exist' error in case several
+       # install-sh are creating the directory concurrently.  This
+       # is OK.
+       test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; }
+      fi
       pathcomp=$pathcomp/
     done
   fi
Index: lib/mkinstalldirs
===================================================================
RCS file: /cvs/automake/automake/lib/mkinstalldirs,v
retrieving revision 1.15
diff -u -r1.15 mkinstalldirs
--- lib/mkinstalldirs   9 Nov 2003 00:10:50 -0000       1.15
+++ lib/mkinstalldirs   15 Feb 2004 20:59:22 -0000
@@ -1,7 +1,7 @@
 #! /bin/sh
 # mkinstalldirs --- make directory hierarchy
 
-scriptversion=2003-11-08.23
+scriptversion=2004-02-15.20
 
 # Original author: Noah Friedman <address@hidden>
 # Created: 1993-05-16
@@ -66,9 +66,15 @@
   0) exit 0 ;;
 esac
 
+# Solaris 8's mkdir -p isn't thread-safe.  If you mkdir -p a/b and
+# mkdir -p a/c at the same time, both will detect that a is missing,
+# one will create a, then the other will try to create a and die with
+# a "File exists" error.  This is a problem when calling mkinstalldirs
+# from a parallel make.  We use --version in the probe to restrict
+# ourselves to GNU mkdir, which is thread-safe.
 case $dirmode in
   '')
-    if mkdir -p -- . 2>/dev/null; then
+    if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
       echo "mkdir -p -- $*"
       exec mkdir -p -- "$@"
     else
@@ -77,16 +83,17 @@
       # directories to create, and then abort because `.' already
       # exists.
       test -d ./-p && rmdir ./-p
-      test -d ./-- && rmdir ./--
+      test -d ./--version && rmdir ./--version
     fi
     ;;
   *)
-    if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
+    if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
+       test ! -d ./--version; then
       echo "mkdir -m $dirmode -p -- $*"
       exec mkdir -m "$dirmode" -p -- "$@"
     else
       # Clean up after NextStep and OpenStep mkdir.
-      for d in ./-m ./-p ./-- "./$dirmode";
+      for d in ./-m ./-p ./--version "./$dirmode";
       do
         test -d $d && rmdir $d
       done
Index: m4/mkdirp.m4
===================================================================
RCS file: /cvs/automake/automake/m4/mkdirp.m4,v
retrieving revision 1.2.2.2
diff -u -r1.2.2.2 mkdirp.m4
--- m4/mkdirp.m4        8 Jan 2004 23:32:26 -0000       1.2.2.2
+++ m4/mkdirp.m4        15 Feb 2004 20:59:22 -0000
@@ -29,8 +29,16 @@
 #
 # Do not use -m 0755 and let people choose whatever they expect by
 # setting umask.
+#
+# We cannot accept any implementation of `mkdir' that recognizes `-p'.
+# Some implementations (such as Solaris 8's) are not thread-safe: if a
+# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
+# concurrently, both version can detect that a/ is missing, but only
+# one can create it and the other will error out.  Consequently we
+# restrict ourselves to GNU make (using the --version option ensures
+# this.)
 AC_DEFUN([AM_PROG_MKDIR_P],
-[if mkdir -p -- . 2>/dev/null; then
+[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
   # Keeping the `.' argument allows $(mkdir_p) to be used without
   # argument.  Indeed, we sometimes output rules like
   #   $(mkdir_p) $(somedir)
@@ -43,7 +51,7 @@
   # recognize any option.  It will interpret all options as
   # directories to create, and then abort because `.' already
   # exists.
-  for d in ./-p ./--;
+  for d in ./-p ./--version;
   do
     test -d $d && rmdir $d
   done
-- 
Alexandre Duret-Lutz





reply via email to

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