This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Fixing mkinstalldirs to avoid non-thread-safe mkdir -p


I'd like to propose this patch for GCC 3.4; it fixes a stupid regression
on Solaris 2.7 / Solaris 8, where mkdir -p is not thread-safe.

The only problem is that mkinstalldirs is copied from automake.  :-P
Is this OK anyway?

I'd actually like to commit this to mainline and src to fix the same problem.
Do I have to get it committed to automake first instead, and worse, do
I have to wait for a 'good' version of automake to be released and used? :-P

I really would rather not deal with this in the other possible way (ad-hoc
changes in various Makefiles), because I expect more such problems to appear
in the future as long as we're using a non-thread-safe version of mkdir -p.

This way also provides a route towards using mkdir -p if and only if
'configure' found that it was on a system where it was OK.

If committing to a variant version of mkinstalldirs is not acceptable,
perhaps I could create a derivative of mkinstalldirs under a different
name and use *that* instead?  

	* mkinstalldirs: Don't use mkdir -p.

Index: mkinstalldirs
===================================================================
RCS file: /cvs/gcc/gcc/mkinstalldirs,v
retrieving revision 1.3
diff -u -r1.3 mkinstalldirs
--- mkinstalldirs	20 Jul 2003 09:40:28 -0000	1.3
+++ mkinstalldirs	8 Feb 2004 07:49:21 -0000
@@ -50,20 +50,24 @@
   0) exit 0 ;;
 esac
 
-case $dirmode in
-  '')
-    if mkdir -p -- . 2>/dev/null; then
-      echo "mkdir -p -- $*"
-      exec mkdir -p -- "$@"
-    fi
-    ;;
-  *)
-    if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
-      echo "mkdir -m $dirmode -p -- $*"
-      exec mkdir -m "$dirmode" -p -- "$@"
-    fi
-    ;;
-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.  So we have to disable this code on Solaris 8.
+#case $dirmode in
+#  '')
+#    if mkdir -p -- . 2>/dev/null; then
+#      echo "mkdir -p -- $*"
+#      exec mkdir -p -- "$@"
+#    fi
+#    ;;
+#  *)
+#    if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
+#      echo "mkdir -m $dirmode -p -- $*"
+#      exec mkdir -m "$dirmode" -p -- "$@"
+#    fi
+#    ;;
+#esac
 
 for file
 do

-- 
Nathanael Nerode  <neroden at gcc.gnu.org>
US citizens: if you're considering voting for Bush, look at these first:
http://www.misleader.org/  http://www.cbc.ca/news/background/arar/
http://www.house.gov/reform/min/politicsandscience/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]