PATCH, build: eliminate races

Ben Elliston bje@au1.ibm.com
Mon Jan 5 10:10:00 GMT 2009


The libcpp and gcc Makefile.ins use the following idiom in their various
pattern rules for generating .po files:

	-test -d po || mkdir po

When building with make -j<N>, where n is large, make tries to generate
many .po files at once.  Numerous shells execute the above command.
Clearly, there is a race between `test -d po' and `mkdir po'.  This
leads to errors from the build system about `po' not being created
because it already exists.  The following patch fixes this, using `mkdir
-p po' instead.

Okay for the trunk?

libcpp/
        * Makefile.in (.po.gmo): Use mkdir -p, not test -d || mkdir.
        (.po.pox): Likewise.
        (po/$(PACKAGE).pot): Likewise.

gcc/
        * Makefile.in (.po.gmo): Use mkdir -p, not test -d || mkdir.
        (.po.pox): Likewise.
        (po/gcc.pot): Likewise.

Index: Makefile.in
===================================================================
--- Makefile.in (revision 143068)
+++ Makefile.in (working copy)
@@ -220,7 +220,7 @@ endif
 
 # N.B. We do not attempt to copy these into $(srcdir).
 .po.gmo:
-       -test -d po || mkdir po
+       mkdir -p po
        $(GMSGFMT) --statistics -o $@ $<
 
 # The new .po has to be gone over by hand, so we deposit it into
@@ -228,7 +228,7 @@ endif
 # If build/po/$(PACKAGE).pot exists, use it (it was just created),
 # else use the one in srcdir.
 .po.pox:
-       -test -d po || mkdir po
+       mkdir -p po
        $(MSGMERGE) $< `if test -f po/$(PACKAGE).pot; \
                        then echo po/$(PACKAGE).pot; \
                        else echo $(srcdir)/po/$(PACKAGE).pot; fi` -o $@
@@ -236,7 +236,7 @@ endif
 # Rule for regenerating the message template.
 $(PACKAGE).pot: po/$(PACKAGE).pot
 po/$(PACKAGE).pot: $(libcpp_a_SOURCES)
-       -test -d $(srcdir)/po || mkdir $(srcdir)/po
+       mkdir -p $(srcdir)/po
        $(XGETTEXT) --default-domain=$(PACKAGE) \
          --keyword=_ --keyword=N_ \
          --keyword=cpp_error:3 --keyword=cpp_errno:3 \
Index: Makefile.in
===================================================================
--- Makefile.in (revision 143068)
+++ Makefile.in (working copy)
@@ -4742,7 +4742,7 @@ update-po: $(CATALOGS:.gmo=.pox)
 # N.B. We do not attempt to copy these into $(srcdir).  The snapshot
 # script does that.
 .po.gmo:
-       -test -d po || mkdir po
+       mkdir -p po
        $(GMSGFMT) --statistics -o $@ $<
 
 # The new .po has to be gone over by hand, so we deposit it into
@@ -4750,7 +4750,7 @@ update-po: $(CATALOGS:.gmo=.pox)
 # If build/po/gcc.pot exists, use it (it was just created),
 # else use the one in srcdir.
 .po.pox:
-       -test -d po || mkdir po
+       mkdir -p po
        $(MSGMERGE) $< `if test -f po/gcc.pot; \
                        then echo po/gcc.pot; \
                        else echo $(srcdir)/po/gcc.pot; fi` -o $@
@@ -4783,7 +4783,7 @@ install-po:
 # The .pot file is left in the build directory.
 gcc.pot: po/gcc.pot
 po/gcc.pot: force
-       -test -d po || mkdir po
+       mkdir -p po
        $(MAKE) srcextra
        AWK=$(AWK) $(SHELL) $(srcdir)/po/exgettext \
                $(XGETTEXT) gcc $(srcdir)




More information about the Gcc-patches mailing list