[m-dev.] for review: GCC back-end: add Mmake support
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Jan 17 20:16:33 AEDT 2001
On 16-Jan-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> On 15-Jan-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > --- compiler/modules.m 2000/12/09 11:03:05 1.141
> > +++ compiler/modules.m 2001/01/15 01:27:43
> > @@ -1793,9 +1793,11 @@
> > ),
> >
> > globals__io_lookup_bool_option(highlevel_code, HighLevelCode),
> > - ( { HighLevelCode = yes } ->
> > + globals__io_get_target(CompilationTarget),
> > + ( { HighLevelCode = yes, CompilationTarget = c } ->
> > %
> > - % For --high-level-code, we need to make sure that we
> > + % For --high-level-code with --target c,
> > + % we need to make sure that we
> > % generate the header files for imported modules
> > % before compiling the C files, since the generated C
> > % files #include those header files.
>
> This was beginning to bug me with the IL backend -- whenever a new .d
> file was generated it demanded a .h file. Changing back and forth
> between asm_fast.gc and ilc meant that I kept needing to run mmake
> depend.
>
> Perhaps this (the fragment above) would be a suitable change for the
> release branch too?
Yes, good idea. Done. I've committed it on the release branch,
with the following log message:
Estimated hours taken: 0.1
compiler/modules.m:
For targets other than C (i.e. IL), don't include the
dependencies on .h files that we normally include for
--high-level-code.
> .maybe_cs seems to be a misleading name in this case.
>
> I can't think of a better one at the moment, so perhaps just document
> it?
Good point. I'll fix the comments. See diff below.
> > Index: scripts/mmake.in
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/scripts/mmake.in,v
> > retrieving revision 1.30
> > diff -u -d -r1.30 mmake.in
> > --- scripts/mmake.in 1999/10/11 05:47:12 1.30
> > +++ scripts/mmake.in 2001/01/14 13:04:38
> > @@ -24,6 +24,11 @@
> > rather than in the current directory.
> > (If the current directory already contains a \`Mercury'
> > subdirectory, then this option is the default.)
> > + --target asm:
> > + Compile directly to assembler, rather than going via C.
> > + --target c:
> > + Compile via C, rather than going directly to assembler.
> > + This is the default.
> > -s, --save-makefile:
> > Save the generated makefile to \`Mmake.makefile'.
> > This is useful for tracking down syntax errors in
>
> --target il doesn't seem to be documented here, but you handle it
> below...
True. It seemed logical to accept `--target il', for consistency with
the other programs (mmc, ml, etc.), but currently it doesn't actually
do anything useful (the code just treats `--target il' as equivalent
to `--target c'), so I didn't document it.
I should have put some comments in the source explaining that
`--target asm' was deliberately undocumented and explaining why.
On further reflection, it's probably also a good idea to issue
a warning for `--target asm'. Fixed, see diff below.
It would probably be nice to make `--target il' do something a bit
more useful, e.g. so that if you type `mmake foo.depend; mmake foo',
it builds foo.exe via IL. But if so, it should be a separate change;
this change was adding Mmake support for the GCC back-end, not for IL ;-)
----------
Estimated hours taken: 0.25
compiler/modules.m:
Add some comments about the use of $(*.maybe_cs) when
compiling to assembler, to address trd's review comment.
Workspace: /home/hg/fjh/gcc-cvs/gcc/mercury
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.142
diff -u -d -r1.142 modules.m
--- compiler/modules.m 2001/01/17 02:43:11 1.142
+++ compiler/modules.m 2001/01/17 08:36:03
@@ -2869,9 +2869,10 @@
},
%
- % We include $(foo.cs) first in the dependency list, before $(foo.os).
+ % When compiling to C, we want to include $(foo.cs) first in
+ % the dependency list, before $(foo.os).
% This is not strictly necessary, since the .$O files themselves depend
- % on the .c files, but we do it to ensure that Make will try to
+ % on the .c files, but want to do it to ensure that Make will try to
% create all the C files first, thus detecting errors early,
% rather than first spending time compiling C files to .$O,
% which could be a waste of time if the program contains errors.
@@ -2882,6 +2883,13 @@
% This needs to be defined here in the .dep file rather than
% in the .dv file since it depends on the setting of the $(RM_C) file
% which can be overridden by the user's Mmakefile.
+ %
+ % When compiling to assembler, we want to do the same kind of
+ % thing, for the same reason, but with the `.s' files rather
+ % than the `.c' files. So if TARGET_ASM=yes, we define
+ % $(foo.maybe_cs) to be $(foo.ss).
+ % XXX The name `.maybe_cs' is a bit misleading in this case.
+ % Perhaps we should change it.
%
module_name_to_file_name(SourceModuleName, "", no, ExeFileName),
io__write_strings(DepStream, [
----------
Estimated hours taken: 0.25
scripts/mmake.in:
Add some comments explaining that the `--target il' option is
not supported. Issue a warning if it is used.
Workspace: /home/hg/fjh/gcc-cvs/gcc/mercury
Index: scripts/mmake.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmake.in,v
retrieving revision 1.31
diff -u -d -r1.31 mmake.in
--- scripts/mmake.in 2001/01/17 02:45:07 1.31
+++ scripts/mmake.in 2001/01/17 09:12:19
@@ -28,7 +28,12 @@
Compile directly to assembler, rather than going via C.
--target c:
Compile via C, rather than going directly to assembler.
- This is the default.
+ This is the default."
+ # XXX `--target il' is not documented because it is not yet
+ # supported.
+ #--target il:
+ # Compile via IL, rather than going via C or assembler.
+Help="$Help\
-s, --save-makefile:
Save the generated makefile to \`Mmake.makefile'.
This is useful for tracking down syntax errors in
@@ -103,7 +108,12 @@
--target)
case "$2" in
asm) target_asm=yes ;;
- c|il) target_asm=no ;;
+ c) target_asm=no ;;
+ il) # XXX we should do something
+ # sensible for `--target il'
+ echo "$0: warning: \`--target il'"
+ "option not supported." 1>&2
+ target_asm=no ;;
*) echo "$0: invalid argument to" \
"\`--target' option" 1>&2
exit 1 ;;
--
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-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