From 02f884a6b55de4ce0cfc34bf363c3cd341733363 Mon Sep 17 00:00:00 2001
From: Nikolay Orlyuk <virkony@gmail.com>
Date: Sat, 5 Jan 2013 20:12:45 +0200
Subject: [PATCH 4/4] fix bug273 (race cond. in slice and deep_profile)

Removed mdbcomp modules copy-in. Instead just include mdbcomp in search
subdirs.

See http://bugs.mercury.csse.unimelb.edu.au/view.php?id=273
---
 deep_profiler/DEEP_FLAGS.in |  3 +++
 deep_profiler/Mmakefile     | 39 +++++----------------------------------
 slice/Mmakefile             | 44 +++++++-------------------------------------
 slice/SLICE_FLAGS.in        |  3 +++
 4 files changed, 18 insertions(+), 71 deletions(-)

diff --git a/deep_profiler/DEEP_FLAGS.in b/deep_profiler/DEEP_FLAGS.in
index d73d03a..cda923a 100644
--- a/deep_profiler/DEEP_FLAGS.in
+++ b/deep_profiler/DEEP_FLAGS.in
@@ -6,6 +6,7 @@
 -I../library
 -I../browser
 -I../ssdb
+-I../mdbcomp
 --c-include-directory ../boehm_gc
 --c-include-directory ../boehm_gc/include
 --c-include-directory ../runtime
@@ -15,6 +16,8 @@
 --c-include-directory ../browser/Mercury/mihs
 --c-include-directory ../ssdb
 --c-include-directory ../ssdb/Mercury/mihs
+--c-include-directory ../mdbcomp
+--c-include-directory ../mdbcomp/Mercury/mihs
 --c-include-directory ../trace
 --csharp-flag -keyfile:../mercury.snk
 --no-java-classpath
diff --git a/deep_profiler/Mmakefile b/deep_profiler/Mmakefile
index c43fc09..2bdf85c 100644
--- a/deep_profiler/Mmakefile
+++ b/deep_profiler/Mmakefile
@@ -54,23 +54,7 @@ else
 	INSTALL=nothing
 endif
 
-VPATH = $(LIBRARY_DIR) $(SSDB_DIR)
-
-#-----------------------------------------------------------------------------#
-
-MDBCOMP_MODULES = \
-	feedback.automatic_parallelism.m \
-	feedback.m \
-	mdbcomp.m \
-	mdbcomp.goal_path.m \
-	prim_data.m \
-	program_representation.m \
-	rtti_access.m \
-	shared_utilities.m \
-	slice_and_dice.m \
-	trace_counts.m
-
-MDBCOMP_ORIG_MODULES = $(patsubst %,$(MDBCOMP_DIR)/%,$(MDBCOMP_MODULES))
+VPATH = $(LIBRARY_DIR) $(MDBCOMP_DIR) $(SSDB_DIR)
 
 #-----------------------------------------------------------------------------#
 
@@ -107,9 +91,9 @@ endif
 nothing:
 
 .PHONY: depend
-depend:	$(MDBCOMP_MODULES) $(DEPEND)
+depend:	$(DEPEND)
 
-$(DEPEND): DEEP_FLAGS $(MDBCOMP_MODULES) Mercury.modules
+$(DEPEND): DEEP_FLAGS Mercury.modules
 
 # This directory contains source files for which the module
 # name doesn't match the file name, so smart recompilation
@@ -119,19 +103,7 @@ Mercury.modules: DEEP_FLAGS
 	$(MC) $(ALL_GRADEFLAGS) $(ALL_MCFLAGS) -f *.m
 
 .PHONY: all
-all:	$(MDBCOMP_MODULES) $(ALL_DEEP_MODULES) $(TAGS_FILE_EXISTS)
-
-# 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)
-	-@chmod a+w $(MDBCOMP_MODULES) > /dev/null 2>&1; exit 0
-	cp $(MDBCOMP_ORIG_MODULES) .
-	@chmod a-w $(MDBCOMP_MODULES)
+all:	$(ALL_DEEP_MODULES) $(TAGS_FILE_EXISTS)
 
 #-----------------------------------------------------------------------------#
 
@@ -231,8 +203,7 @@ cs: $(mdprof_procrep.cs) $(cs_subdir)mdprof_procrep_init.c
 #-----------------------------------------------------------------------------#
 
 realclean_local:
-	rm -f .deep_tags tags DEEP_FLAGS DEEP_FLAGS.date \
-		$(MDBCOMP_MODULES) mdbcomp.*.err
+	rm -f .deep_tags tags DEEP_FLAGS DEEP_FLAGS.date
 
 #-----------------------------------------------------------------------------#
 
diff --git a/slice/Mmakefile b/slice/Mmakefile
index cdfca10..7ef40e4 100644
--- a/slice/Mmakefile
+++ b/slice/Mmakefile
@@ -42,23 +42,7 @@ INTS	= $(patsubst %,%.ints,$(MERCURY_MAIN_MODULES))
 INT3S	= $(patsubst %,%.int3s,$(MERCURY_MAIN_MODULES))
 CHECKS	= $(patsubst %,%.check,$(MERCURY_MAIN_MODULES))
 
-VPATH = $(LIBRARY_DIR) $(SSDB_DIR)
-
-#-----------------------------------------------------------------------------#
-
-MDBCOMP_MODULES = \
-	feedback.automatic_parallelism.m \
-	feedback.m \
-	mdbcomp.m \
-	mdbcomp.goal_path.m \
-	prim_data.m \
-	program_representation.m \
-	rtti_access.m \
-	shared_utilities.m \
-	slice_and_dice.m \
-	trace_counts.m
-
-MDBCOMP_ORIG_MODULES = $(patsubst %,$(MDBCOMP_DIR)/%,$(MDBCOMP_MODULES))
+VPATH = $(LIBRARY_DIR) $(MDBCOMP_DIR) $(SSDB_DIR)
 
 #-----------------------------------------------------------------------------#
 
@@ -82,26 +66,12 @@ endif
 #-----------------------------------------------------------------------------#
 
 .PHONY: depend
-depend:	$(MDBCOMP_MODULES) $(DEPENDS)
+depend:	$(DEPENDS)
 
-$(DEPENDS): SLICE_FLAGS $(MDBCOMP_MODULES)
+$(DEPENDS): SLICE_FLAGS
 
 .PHONY: all
-all:	$(MDBCOMP_MODULES) $(MERCURY_MAIN_MODULES) $(TAGS_FILE_EXISTS)
-
-#-----------------------------------------------------------------------------#
-#
-# 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)
-	-@chmod a+w $(MDBCOMP_MODULES) > /dev/null 2>&1; exit 0
-	cp $(MDBCOMP_ORIG_MODULES) .
-	@chmod a-w $(MDBCOMP_MODULES)
+all:	$(MERCURY_MAIN_MODULES) $(TAGS_FILE_EXISTS)
 
 #-----------------------------------------------------------------------------#
 
@@ -157,7 +127,8 @@ ints:	$(INTS)
 tags:	.slice_tags
 
 .slice_tags: $(MTAGS) $(mslice.ms) $(mdice.ms) $(mtc_union.ms) $(mcov.ms) \
-		$(mtc_diff.ms) $(wildcard $(LIBRARY_DIR)/*.m)
+		$(mtc_diff.ms) $(wildcard $(LIBRARY_DIR)/*.m) \
+		$(wildcard $(MDBCOMP_DIR)/*.m)
 	$(MTAGS) $(mslice.ms) $(mdice.ms) $(mtc_union.ms) $(mcov.ms) \
 		$(mtc_diff.ms) $(LIBRARY_DIR)/*.m
 	@touch .slice_tags
@@ -194,8 +165,7 @@ ils:	$(mslice.ils) $(mdice.ils) $(mtc_union.ils) $(mcov.ils) $(mtc_diff.ils)
 #-----------------------------------------------------------------------------#
 
 realclean_local:
-	rm -f tags SLICE_FLAGS SLICE_FLAGS.date \
-		$(MDBCOMP_MODULES) mdbcomp.*.err
+	rm -f tags SLICE_FLAGS SLICE_FLAGS.date
 
 #-----------------------------------------------------------------------------#
 
diff --git a/slice/SLICE_FLAGS.in b/slice/SLICE_FLAGS.in
index 2a4321c..78bde9e 100644
--- a/slice/SLICE_FLAGS.in
+++ b/slice/SLICE_FLAGS.in
@@ -6,6 +6,7 @@
 -I../library
 -I../browser
 -I../ssdb
+-I../mdbcomp
 --c-include-directory ../boehm_gc
 --c-include-directory ../boehm_gc/include
 --c-include-directory ../runtime
@@ -15,6 +16,8 @@
 --c-include-directory ../browser/Mercury/mihs
 --c-include-directory ../ssdb
 --c-include-directory ../ssdb/Mercury/mihs
+--c-include-directory ../mdbcomp
+--c-include-directory ../mdbcomp/Mercury/mihs
 --c-include-directory ../trace
 --csharp-flag -keyfile:../mercury.snk
 --no-java-classpath
-- 
1.8.0.3

