[m-rev.] for review: fix foreign_decls in the LLDS grades

Peter Ross pro at missioncriticalit.com
Wed Aug 7 21:10:55 AEST 2002


On Wed, Aug 07, 2002 at 08:40:54PM +1000, Simon Taylor wrote:
> On 07-Aug-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> > The directory search in this change could be avoided by depending on the
> > .mh files, but only if the code in export.m was changed so that we alway
> > output a .mh file.
> > 
> > If that change is prefered, then let me know.
> 
> I think that would be the better (and simpler) solution.
> It would also allow the `.o' files to depend on the `.mh'
> file for the imported modules rather than the `.c' file,
> which will cause less unnecessary recompilation.
> 

Here is the change.

Please review it.

===================================================================


Estimated hours taken: 0.5
Branches: main

When intermodule optimization is enabled make the .o file depend on all
the possible imported .mh files.  This avoids unneccessary recompilation
because the .mh files are less likely to change, as well as a directory
search for .m files.

compiler/export.m:
    Always produce a .mh file because intermodule optimization relies on
    it.

compiler/modules.m:
    Make the .o file depend on all the possible .mh files which could be
    imported when intermodule optimization is enabled.

Index: compiler/export.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/export.m,v
retrieving revision 1.62
diff -u -r1.62 export.m
--- compiler/export.m	5 Aug 2002 21:46:08 -0000	1.62
+++ compiler/export.m	7 Aug 2002 10:57:15 -0000
@@ -605,12 +605,11 @@
 % Should this predicate go in llds_out.m?
 
 export__produce_header_file(ForeignExportDecls, ModuleName) -->
-	( { ForeignExportDecls = foreign_export_decls([], []) } ->
-		[]
-	;
-		export__produce_header_file(ForeignExportDecls,
-				ModuleName, ".mh")
-	).
+		% We always produce a .mh file because with intermodule
+		% optimization enabled the .o file depends on all the
+		% .mh files of the imported modules so we always need to
+		% produce a .mh file even if it contains nothing.
+	export__produce_header_file(ForeignExportDecls, ModuleName, ".mh").
 
 :- pred export__produce_header_file(foreign_export_decls,
 		module_name, string, io__state, io__state).
Index: compiler/modules.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/modules.m,v
retrieving revision 1.243
diff -u -r1.243 modules.m
--- compiler/modules.m	7 Aug 2002 10:22:06 -0000	1.243
+++ compiler/modules.m	7 Aug 2002 10:59:15 -0000
@@ -2065,17 +2065,15 @@
 			IntermodDirs),
 
 			% If intermodule_optimization is enabled then
-			% build all the .c files for modules that exist in
-			% the current directory before the .o files to
-			% avoid problems with foreign_import_module
-			% dependencies not being correctly calculated.
+			% all the .mh files must exist because it is
+			% possible that the .c file imports them
+			% directly or indirectly.
 		( { Intermod = yes } ->
 			io__write_strings(DepStream, [
 				"\n\n",
 				ObjFileName, " : "
 			]),
-			source_files_in_current_dir(AllDeps, CurrentDirDeps),
-			write_dependencies_list(CurrentDirDeps, ".c", DepStream)
+			write_dependencies_list(AllDeps, ".mh", DepStream)
 		;
 			[]
 		),
@@ -2561,19 +2559,6 @@
 			maybe_write_string(Verbose, " done.\n")
 		)
 	).
-
-:- pred source_files_in_current_dir(list(module_name)::in,
-		list(module_name)::out, io__state::di, io__state::uo) is det.
-
-source_files_in_current_dir([], []) --> [].
-source_files_in_current_dir([Module | Modules], FoundModules) -->
-	source_files_in_current_dir(Modules, FoundModules0),
-	search_for_module_source(["."], Module, Result),
-	{ Result = ok(_),
-		FoundModules = [Module | FoundModules0]
-	; Result = error(_),
-		FoundModules = FoundModules0
-	}.
 
 	% Generate the following dependency.  This dependency is
 	% needed because module__cpp_code.dll might refer to
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list