[m-rev.] diff: fix MCFLAGS-<module> bug
Simon Taylor
stayl at cs.mu.OZ.AU
Wed Jun 26 00:25:15 AEST 2002
On 25-Jun-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
>
> Estimated hours taken: 1
> Branches: main
>
> scripts/Mmake.vars.in:
> The code to look up the target-specific MCFLAGS variable
> assumed that mmc is always invoked by a pattern rule, which
> isn't true if the module name doesn't match the file name.
Estimated hours taken: 1.5
Branches: main
My change to fix the handling of target specific MCFLAGS
variables didn't work with `--split-c-files'.
compiler/modules.m:
Fix some bugs in the handling of `--split-c-files':
- Make `--split-c-files' work where the module name doesn't
match the file name.
- $(MCFLAGS-module) wasn't being passed to mmc when `module.dir/*.o'
were being rebuilt (it was being passed when the files were
being built from scratch).
scripts/Mmake.rules:
The pattern rule for `%.dir/*.o' is now redundant, so remove it.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.235
diff -u -u -r1.235 modules.m
--- compiler/modules.m 22 Jun 2002 19:15:55 -0000 1.235
+++ compiler/modules.m 25 Jun 2002 13:44:02 -0000
@@ -2236,16 +2236,46 @@
write_dependencies_list(LongDeps, ".int3", DepStream),
write_dependencies_list(ShortDeps, ".int3", DepStream),
+ %
+ % If we can pass the module name rather than the
+ % file name then do so. `--smart-recompilation'
+ % doesn't work if the file name is passed and the
+ % module name doesn't match the file name.
+ %
+ have_source_file_map(HaveMap),
+ { HaveMap = yes,
+ prog_out__sym_name_to_string(
+ SourceFileModuleName, ".", ModuleArg)
+ ; HaveMap = no,
+ ModuleArg = SourceFileName
+ },
+
+ %
+ % XXX The rule below will cause an undefined make
+ % variable warning for $(MCFLAGS-module) when run,
+ % but there's no easy way to avoid that without using
+ % features only available in recent versions of make.
+ % The special case handling of $(MCFLAGS-module) in
+ % this rule is necessary because it's difficult to extract
+ % the module name from $@ (e.g. module.dir/module_000.o) in
+ % the code for TARGET_MCFLAGS in Mmake.vars.in using make's
+ % text handling functions ($(patsubst ...) only works for a
+ % single occurrence of the pattern).
+ %
+ % With recent versions of make (3.78 or later) it would be
+ % possible to avoid the warning using
+ % $(if $(findstring undefined,$(origin MCFLAGS-module)),,\
+ % $(MCFLAGS-module))
+ %
module_name_to_file_name(ModuleName, ".dir", no, DirFileName),
- module_name_to_split_c_file_name(ModuleName, 0, ".$O",
- SplitCObj0FileName),
io__write_strings(DepStream, [
"\n\n",
- SplitCObj0FileName, " : ",
+ SplitObjPattern, " : ",
SourceFileName, "\n",
"\trm -rf ", DirFileName, "\n",
"\t$(MCS) $(ALL_GRADEFLAGS) $(ALL_MCSFLAGS) ",
- SourceFileName, "\n\n"
+ "$(MCFLAGS-", MakeVarName, ") ",
+ ModuleArg, "\n\n"
]),
globals__io_get_target(Target),
@@ -2411,20 +2441,6 @@
% file for documentation on these rules.
%
- %
- % If we can pass the module name rather than the
- % file name then do so. `--smart-recompilation'
- % doesn't work if the file name is passed and the
- % module name doesn't match the file name.
- %
- have_source_file_map(HaveMap),
- { HaveMap = yes,
- prog_out__sym_name_to_string(
- SourceFileModuleName, ".", ModuleArg)
- ; HaveMap = no,
- ModuleArg = SourceFileName
- },
-
io__write_strings(DepStream, [
"\n",
Date0FileName, " : ", SourceFileName, "\n",
@@ -3614,7 +3630,7 @@
io__write_string(DepStream, MakeVarName),
io__write_string(DepStream, ".num_splits = "),
write_compact_dependencies_list(Modules, "$(num_splits_subdir)",
- ".num_splits", Basis, DepStream),
+ ".num_split", Basis, DepStream),
io__write_string(DepStream, "\n"),
io__write_string(DepStream, MakeVarName),
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.rules,v
retrieving revision 1.127
diff -u -u -r1.127 Mmake.rules
--- scripts/Mmake.rules 22 Jun 2002 19:16:10 -0000 1.127
+++ scripts/Mmake.rules 25 Jun 2002 09:15:38 -0000
@@ -285,15 +285,6 @@
cp $(MERC_DLL_DIR)/mercury.sn .
endif
-# For --split-c-files, we generate the .$O files directly from the .m files.
-# (One reason for this is that there's no easy of telling Make how many
-# `.$O' files it should make, since the number of them depends on what's
-# in the source files.)
-
-$(dirs_subdir)%.dir/*.$O: %.m
- rm -f $@
- $(MCS) $(ALL_GRADEFLAGS) $(ALL_MCSFLAGS) $(*F)
-
# The `touch' is necessary, since otherwise if
# the old .err file was of size zero and
# the new .err file is also of size zero,
--------------------------------------------------------------------------
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