[m-rev.] Fix race conditions for the 'depend' make target.
Paul Bone
paul at bone.id.au
Wed Jan 9 16:11:41 AEDT 2013
Fix the race conditions in the deep_profiler and slice directories when they
copy the mdbcomp files in.
deep_profiler/Mmakefile:
slice/Mmakefile:
As above.
---
deep_profiler/Mmakefile | 13 +++++++++++--
slice/Mmakefile | 13 +++++++++++--
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/deep_profiler/Mmakefile b/deep_profiler/Mmakefile
index c43fc09..1ab7af8 100644
--- a/deep_profiler/Mmakefile
+++ b/deep_profiler/Mmakefile
@@ -121,17 +121,26 @@ Mercury.modules: DEEP_FLAGS
.PHONY: all
all: $(MDBCOMP_MODULES) $(ALL_DEEP_MODULES) $(TAGS_FILE_EXISTS)
+# We use the sentinel file .mdbcomp_modules to avoid the race condition that
+# exists because the rule would normally be invoked for each of the mdbcomp
+# modules. Note that a .PHONY target does not work. However, we also need
+# to use the no-op action '@' to allow make to see that the timestamps on
+# the $(MDBCOMP_MODULES) have changed and that other things may need
+# rebuilding.
+$(MDBCOMP_MODULES): .mdbcomp_modules
+ @
+
# We need to start by turning write permission on for each copied file
# in case some exist, but we need to ignore errors in case some don't exist.
# The exit 0 is to prevent make itself from printing a message about the
# (ignored) failure of an action.
#
# We could modify the action here to copy only the changed files.
-
-$(MDBCOMP_MODULES): $(MDBCOMP_ORIG_MODULES)
+.mdbcomp_modules : $(MDBCOMP_ORIG_MODULES)
- at chmod a+w $(MDBCOMP_MODULES) > /dev/null 2>&1; exit 0
cp $(MDBCOMP_ORIG_MODULES) .
@chmod a-w $(MDBCOMP_MODULES)
+ touch $@
#-----------------------------------------------------------------------------#
diff --git a/slice/Mmakefile b/slice/Mmakefile
index cdfca10..4366d36 100644
--- a/slice/Mmakefile
+++ b/slice/Mmakefile
@@ -91,17 +91,26 @@ all: $(MDBCOMP_MODULES) $(MERCURY_MAIN_MODULES) $(TAGS_FILE_EXISTS)
#-----------------------------------------------------------------------------#
#
+# We use the sentinel file .mdbcomp_modules to avoid the race condition that
+# exists because the rule would normally be invoked for each of the mdbcomp
+# modules. Note that a .PHONY target does not work. However, we also need
+# to use the no-op action '@' to allow make to see that the timestamps on
+# the $(MDBCOMP_MODULES) have changed and that other things may need
+# rebuilding.
+$(MDBCOMP_MODULES): .mdbcomp_modules
+ @
+
# We need to start by turning write permission on for each copied file
# in case some exist, but we need to ignore errors in case some don't exist.
# The exit 0 is to prevent make itself from printing a message about the
# (ignored) failure of an action.
#
# We could modify the action here to copy only the changed files.
-
-$(MDBCOMP_MODULES): $(MDBCOMP_ORIG_MODULES)
+.mdbcomp_modules : $(MDBCOMP_ORIG_MODULES)
- at chmod a+w $(MDBCOMP_MODULES) > /dev/null 2>&1; exit 0
cp $(MDBCOMP_ORIG_MODULES) .
@chmod a-w $(MDBCOMP_MODULES)
+ touch $@
#-----------------------------------------------------------------------------#
--
1.7.2.5
More information about the reviews
mailing list