diff: fix bug with fact tables & --use-subdirs
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue Feb 9 09:32:46 AEDT 1999
Estimated hours taken: 1
compiler/modules.m:
Fix a bug with the dependencies computed when using
both fact tables and `--use-subdirs'.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.91
diff -u -r1.91 modules.m
--- modules.m 1998/11/02 09:49:04 1.91
+++ modules.m 1999/02/08 22:15:46
@@ -503,7 +503,17 @@
choose_file_name(ModuleName, BaseName, Ext, MkDir, FileName).
fact_table_file_name(ModuleName, FactTableFileName, Ext, FileName) -->
- { string__append(FactTableFileName, Ext, BaseName) },
+ extra_link_obj_file_name(ModuleName, FactTableFileName, Ext, FileName).
+
+ % extra_link_obj_file_name(Module, ExtraLinkObjName, Ext, FileName):
+ % Returns the filename to use when compiling extra objects
+ % that must be linked into the executable
+ % (currently used only for fact tables).
+:- pred extra_link_obj_file_name(module_name, file_name, string, file_name,
+ io__state, io__state).
+:- mode extra_link_obj_file_name(in, in, in, out, di, uo) is det.
+extra_link_obj_file_name(ModuleName, ExtraLinkObjName, Ext, FileName) -->
+ { string__append(ExtraLinkObjName, Ext, BaseName) },
choose_file_name(ModuleName, BaseName, Ext, no, FileName).
:- pred choose_file_name(module_name, string, string, bool, file_name,
@@ -2251,14 +2261,14 @@
io__write_string(DepStream, ".cs = "),
write_compact_dependencies_list(Modules, "$(cs_subdir)", ".c",
Basis, DepStream),
- write_file_dependencies_list(ExtraLinkObjs, ".c", DepStream),
+ write_extra_link_dependencies_list(ExtraLinkObjs, ".c", DepStream),
io__write_string(DepStream, "\n"),
io__write_string(DepStream, MakeVarName),
io__write_string(DepStream, ".os = "),
write_compact_dependencies_list(Modules, "$(os_subdir)", ".o",
Basis, DepStream),
- write_file_dependencies_list(ExtraLinkObjs, ".o", DepStream),
+ write_extra_link_dependencies_list(ExtraLinkObjs, ".o", DepStream),
io__write_string(DepStream, "\n"),
io__write_string(DepStream, MakeVarName),
@@ -2635,14 +2645,16 @@
% get_extra_link_objects(Modules, DepsMap, ExtraLinkObjs) },
% Find any extra .o files that should be linked into the executable.
% Currently only looks for fact table object files.
-:- pred get_extra_link_objects(list(module_name), deps_map, list(string)).
+:- pred get_extra_link_objects(list(module_name), deps_map,
+ assoc_list(file_name, module_name)).
:- mode get_extra_link_objects(in, in, out) is det.
get_extra_link_objects(Modules, DepsMap, ExtraLinkObjs) :-
get_extra_link_objects_2(Modules, DepsMap, [], ExtraLinkObjs).
:- pred get_extra_link_objects_2(list(module_name), deps_map,
- list(string), list(string)).
+ assoc_list(file_name, module_name),
+ assoc_list(file_name, module_name)).
:- mode get_extra_link_objects_2(in, in, in, out) is det.
get_extra_link_objects_2([], _DepsMap, ExtraLinkObjs, ExtraLinkObjs).
@@ -2650,7 +2662,11 @@
ExtraLinkObjs0, ExtraLinkObjs) :-
map__lookup(DepsMap, Module, deps(_, ModuleImports)),
ModuleImports = module_imports(_, _, _, _, _, _, _, FactDeps, _, _),
- list__append(FactDeps, ExtraLinkObjs0, ExtraLinkObjs1),
+ list__length(FactDeps, NumFactDeps),
+ list__duplicate(NumFactDeps, Module, ModuleList),
+ assoc_list__from_corresponding_lists(FactDeps, ModuleList,
+ NewLinkObjs),
+ list__append(NewLinkObjs, ExtraLinkObjs0, ExtraLinkObjs1),
get_extra_link_objects_2(Modules, DepsMap, ExtraLinkObjs1,
ExtraLinkObjs).
@@ -2686,7 +2702,6 @@
:- pred write_fact_table_dependencies_list(module_name, list(file_name),
string, io__output_stream, io__state, io__state).
:- mode write_fact_table_dependencies_list(in, in, in, in, di, uo) is det.
-
write_fact_table_dependencies_list(_, [], _, _) --> [].
write_fact_table_dependencies_list(Module, [FactTable | FactTables], Suffix,
DepStream) -->
@@ -2695,6 +2710,18 @@
io__write_string(DepStream, FileName),
write_fact_table_dependencies_list(Module, FactTables, Suffix,
DepStream).
+
+:- pred write_extra_link_dependencies_list(assoc_list(file_name, module_name),
+ string, io__output_stream, io__state, io__state).
+:- mode write_extra_link_dependencies_list(in, in, in, di, uo) is det.
+
+write_extra_link_dependencies_list([], _, _) --> [].
+write_extra_link_dependencies_list([ExtraLink - Module | ExtraLinks], Suffix,
+ DepStream) -->
+ extra_link_obj_file_name(Module, ExtraLink, Suffix, FileName),
+ io__write_string(DepStream, " \\\n\t"),
+ io__write_string(DepStream, FileName),
+ write_extra_link_dependencies_list(ExtraLinks, Suffix, DepStream).
:- pred write_file_dependencies_list(list(string), string, io__output_stream,
io__state, io__state).
--
Fergus Henderson <fjh at cs.mu.oz.au> | "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh> | but source code lives forever"
PGP: finger fjh at 128.250.37.3 | -- leaked Microsoft memo.
More information about the developers
mailing list