[m-dev.] For review: bug fixes for split library files

Warwick Harvey wharvey at cs.monash.edu.au
Tue Aug 17 18:30:22 AEST 1999


For anyone to review.


Estimated hours taken: 2

This fixes two bugs in mmake's handling of split library files.  The first
was that the `clean' target(s) did not remove the `.dir' directories for any
modules except the top-level one(s).  The second was that the split files
generated did not depend on the relevant interface and optimisation files,
so mmake sometimes tried to generate the split files with some necessary
files either missing or out-of-date.

compiler/modules.m:
	Changed an entry in the `clean' target generated in `.dep' files to
	remove `$(<module>.dirs)' rather than just `<module>.dir'.
	Added a dependency between the `.o' files generated by the split
	library targets and the relevant `.int', `.opt' and `.trans_opt'
	files.  As part of this, introduced a new predicate
	`module_name_to_split_c_file_pattern', which is like
	`module_name_to_split_c_file_name' but generates a wildcard pattern
	rather than a specific file name.


Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.105
diff -u -r1.105 modules.m
--- modules.m	1999/08/03 01:36:43	1.105
+++ modules.m	1999/08/17 08:14:27
@@ -88,6 +88,14 @@
 				io__state, io__state).
 :- mode module_name_to_split_c_file_name(in, in, in, out, di, uo) is det.
 
+	% module_name_to_split_c_file_pattern(Module, Extension, FileName):
+	%	Like module_name_to_split_c_file_name, but generates a
+	%	wildcard pattern to match all such files with the given
+	%	extension for the given module.
+:- pred module_name_to_split_c_file_pattern(module_name, string, file_name,
+				io__state, io__state).
+:- mode module_name_to_split_c_file_pattern(in, in, out, di, uo) is det.
+
 	% fact_table_file_name(Module, FactTableFileName, Ext, FileName):
 	%	Returns the filename to use when compiling fact table
 	%	files.
@@ -632,6 +640,13 @@
 		[s(DirName), c(Slash), s(BaseFileName), i(Num), s(Ext)],
 		FileName) }.
 
+module_name_to_split_c_file_pattern(ModuleName, Ext, Pattern) -->
+	module_name_to_file_name(ModuleName, ".dir", no, DirName),
+	{ dir__directory_separator(Slash) },
+	{ string__format("%s%c*%s",
+		[s(DirName), c(Slash), s(Ext)],
+		Pattern) }.
+
 file_name_to_module_name(FileName, ModuleName) :-
 	string_to_sym_name(FileName, ".", ModuleName).
 
@@ -1439,6 +1454,8 @@
 		module_name_to_file_name(ModuleName, ".rlo", no, RLOFileName),
 		module_name_to_file_name(ModuleName, ".pic_o", no,
 							PicObjFileName),
+		module_name_to_split_c_file_pattern(ModuleName, ".o",
+			SplitObjPattern),
 		io__write_strings(DepStream, ["\n\n",
 			OptDateFileName, " ",
 			TransOptDateFileName, " ",
@@ -1446,6 +1463,7 @@
 			ErrFileName, " ",
 			PicObjFileName, " ",
 			ObjFileName, " ",
+			SplitObjPattern, " ",
 			RLOFileName, " : ",
 			SourceFileName
 		] ),
@@ -1478,7 +1496,8 @@
 				TransOptDateFileName, " ",
 				ErrFileName, " ", 
 				PicObjFileName, " ",
-				ObjFileName, " :"
+				ObjFileName, " ",
+				SplitObjPattern, " :"
 			]),
 
 			% The .c file only depends on the .opt files from 
@@ -1507,7 +1526,8 @@
 					CFileName, " ",
 					ErrFileName, " ", 
 					PicObjFileName, " ", 
-					ObjFileName, " :"
+					ObjFileName, " ",
+					SplitObjPattern, " :"
 				]),
 				write_dependencies_list(TransOptDeps,
 					".trans_opt", DepStream)
@@ -2641,7 +2661,7 @@
 	io__write_strings(DepStream, [
 		".PHONY : ", CleanTargetName, "\n",
 		CleanTargetName, " :\n",
-		"\t-rm -rf ", MakeVarName, ".dir\n",
+		"\t-rm -rf $(", MakeVarName, ".dirs)\n",
 		"\t-rm -f $(", MakeVarName, ".cs) ", InitCFileName, "\n",
 		"\t-rm -f $(", MakeVarName, ".ss) ", InitAsmFileName, "\n",
 		"\t-rm -f $(", MakeVarName, ".os) ", InitObjFileName, "\n",
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list