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

Peter Ross pro at missioncriticalit.com
Wed Aug 7 20:30:34 AEST 2002


On Wed, Aug 07, 2002 at 11:44:55AM +1000, David Overton wrote:
> Hi Pete,
> 
> On Mon, Aug 05, 2002 at 03:16:24PM +0200, Peter Ross wrote:
> > --- mercury/compiler/modules.m	29 Jul 2002 07:50:55 -0000	1.241
> > +++ mercury/compiler/modules.m	5 Aug 2002 12:45:17 -0000
> > @@ -2063,6 +2063,20 @@
> >  			Intermod),
> >  		globals__io_lookup_accumulating_option(intermod_directories,
> >  			IntermodDirs),
> > +
> > +			% If intermodule_optimization is enabled then
> > +			% build all the .c files before the .o files to
> > +			% avoid problems with foreign_import_module
> > +			% dependencies not being correctly calculated.
> > +		( { Intermod = yes } ->
> > +			io__write_strings(DepStream, [
> > +				"\n\n",
> > +				ObjFileName, " : "
> > +			]),
> > +			write_dependencies_list(AllDeps, ".c", DepStream)
> > +		;
> > +			[]
> > +		),
> >  		( { Intermod = yes ; UseOptFiles = yes } ->
> >  			io__write_strings(DepStream, [
> >  				"\n\n", 
> 
> I think this change is buggy.  E.g. when compiling a program "warplan",
> `warplan.d' contains
> 
Here is the fix.

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 have checked this change in for the moment though.

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


Estimated hours taken: 0.5
Branches: main

Fix a bug where with intermodule optimization enabled a dependency would
be generated to a .c file which resides in a different directory.

compiler/modules.m:
    Only allow a .o file to depend on .c files which reside in the
    current directory.

Index: compiler/modules.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/modules.m,v
retrieving revision 1.242
diff -u -r1.242 modules.m
--- compiler/modules.m	5 Aug 2002 21:46:14 -0000	1.242
+++ compiler/modules.m	7 Aug 2002 09:58:32 -0000
@@ -2065,7 +2065,8 @@
 			IntermodDirs),
 
 			% If intermodule_optimization is enabled then
-			% build all the .c files before the .o files to
+			% 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.
 		( { Intermod = yes } ->
@@ -2073,7 +2074,8 @@
 				"\n\n",
 				ObjFileName, " : "
 			]),
-			write_dependencies_list(AllDeps, ".c", DepStream)
+			source_files_in_current_dir(AllDeps, CurrentDirDeps),
+			write_dependencies_list(CurrentDirDeps, ".c", DepStream)
 		;
 			[]
 		),
@@ -2559,6 +2561,19 @@
 			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