[m-rev.] diff: GCC back-end: fix bug with mmake install
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed May 9 01:11:19 AEST 2001
Estimated hours taken: 1
Fix a bug in the Mmake support for the GCC back-end.
compiler/modules.m:
Change the generation of the $(foo.hs) variable for --target asm
so that it matches the actual .h files that are output.
Add $(foo.all_hs) which contains the full set of headers,
i.e. what $(foo.hs) used to contain.
This is needed to prevent `mmake --target asm foo.install'
from failing, because Mmake wants to install $(foo.hs), which
previously included files that don't get built with --target asm.
There are still some outstanding problems, because the header
files used for hlc.gc with and without --target asm are different.
But a similar issue arises for --high-level-data. This fix
does seem to be an improvement, even if it doesn't solve all
the problems.
Workspace: /mnt/hg/home/hg/fjh/gcc-cvs/gcc/mercury
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.160
diff -u -d -r1.160 modules.m
--- compiler/modules.m 2001/05/08 08:56:32 1.160
+++ compiler/modules.m 2001/05/08 08:56:40
@@ -2793,6 +2793,40 @@
io__write_string(DepStream, MakeVarName),
io__write_string(DepStream, ".hs = "),
+ globals__io_lookup_bool_option(highlevel_code, HighLevelCode),
+ ( { HighLevelCode = yes } ->
+ ( { Target = asm } ->
+ % For the `--target asm' back-end, we only
+ % generate `.h' files for modules that
+ % contain C code
+ write_dependencies_list(
+ modules_that_need_headers(Modules, DepsMap),
+ ".h", DepStream)
+ ; { Target = c } ->
+ % For the `--target c' MLDS back-end, we
+ % generate `.h' files for every module
+ write_compact_dependencies_list(Modules, "", ".h",
+ Basis, DepStream)
+ ;
+ % For the IL and Java targets, currently we don't
+ % generate `.h' files at all; although perhaps
+ % we should...
+ []
+ )
+ ;
+ % For the LLDS back-end, we don't use `.h' files at all
+ []
+ ),
+ io__write_string(DepStream, "\n"),
+
+ % The `<module>.all_hs' variable is like `<module>.hs' except
+ % that it contains header files for all the modules, regardless
+ % of the grade or --target option. It is used by the rule for
+ % `mmake realclean', which should remove anything that could have
+ % been automatically generated, even if the grade or --target option
+ % has changed.
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".all_hs = "),
write_compact_dependencies_list(Modules, "", ".h", Basis, DepStream),
io__write_string(DepStream, "\n"),
@@ -3195,7 +3229,7 @@
"\t-rm -f $(", MakeVarName, ".opts)\n",
"\t-rm -f $(", MakeVarName, ".trans_opts)\n",
"\t-rm -f $(", MakeVarName, ".ds)\n",
- "\t-rm -f $(", MakeVarName, ".hs)\n",
+ "\t-rm -f $(", MakeVarName, ".all_hs)\n",
"\t-rm -f $(", MakeVarName, ".rlos)\n"
]),
io__write_strings(DepStream, [
@@ -3239,6 +3273,22 @@
%-----------------------------------------------------------------------------%
+ % Find out which modules we need to generate C header files for,
+ % assuming we're compiling with `--target asm'.
+:- func modules_that_need_headers(list(module_name), deps_map) =
+ list(module_name).
+
+modules_that_need_headers(Modules, DepsMap) =
+ list__filter(module_needs_header(DepsMap), Modules).
+
+ % Succeed iff we need to generate a C header file for the specified
+ % module, assuming we're compiling with `--target asm'.
+:- pred module_needs_header(deps_map::in, module_name::in) is semidet.
+
+module_needs_header(DepsMap, Module) :-
+ map__lookup(DepsMap, Module, deps(_, ModuleImports)),
+ ModuleImports ^ foreign_code = contains_foreign_code.
+
% get_extra_link_objects(Modules, DepsMap, Target, ExtraLinkObjs) },
% Find any extra .$O files that should be linked into the executable.
% These include fact table object files and object files for foreign
@@ -3248,7 +3298,8 @@
:- mode get_extra_link_objects(in, in, in, out) is det.
get_extra_link_objects(Modules, DepsMap, Target, ExtraLinkObjs) :-
- get_extra_link_objects_2(Modules, DepsMap, Target, [], ExtraLinkObjs).
+ get_extra_link_objects_2(Modules, DepsMap, Target, [], ExtraLinkObjs0),
+ list__reverse(ExtraLinkObjs0, ExtraLinkObjs).
:- pred get_extra_link_objects_2(list(module_name), deps_map,
compilation_target, assoc_list(file_name, module_name),
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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