[m-rev.] for review: fix smart recompilation bug
Simon Taylor
stayl at cs.mu.OZ.AU
Thu Jul 5 00:12:06 AEST 2001
On 04-Jul-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 04-Jul-2001, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> The code in compiler/modules.m which calculates foo_s_dates is wrong for
> `--target asm'; but it is copied from the code which calculates foo_ss,
> which is also wrong. The way we calculate `foo_os' is the right way.
Fixed, but I'm pretty sure the code to handle `.pic_s' is also wrong (it
needs to be handled as for `.pic_o'). I'll leave that to you.
> > Index: compiler/mercury_compile.m
> > + module_name_to_file_name(ModuleName,
> > + TimestampSuffix, no, FileName),
> > + { TimestampFiles = [FileName] }
>
> Hmm, is the "no" there correct?
Fixed.
> > +++ compiler/modules.m 2001/07/03 09:59:17
> > + % touch_file(FileName).
> > + %
> > + % Update the modification time for file `FileName'.
> > +
> > +:- pred touch_file(file_name, io__state, io__state).
> > +:- mode touch_file(in, di, uo) is det.
>
> The name and documentation of that procedure are misleading;
> what the code does is not just to update the modification time,
> but also to clobber the file contents.
Fixed.
Simon.
Estimated hours taken: 3
Use a timestamp file mechanism similar to that used for `.int' files
to avoid rechecking whether a module needs to be recompiled on each
mmake if no used interfaces have changed.
compiler/mercury_compile.m:
Touch a `.c_date', `.il_date', `.s_date' or `.pic_s_date' file
after compilation has finished.
compiler/recompilation_check.m:
Touch a `.c_date', `.il_date', `.s_date' or `.pic_s_date' file
if a module does not need to be recompiled.
compiler/modules.m:
scripts/Mmake.rules:
Set up the make dependencies for timestamp files, in a similar
manner to the `.date' files.
Remove the timestamp files in the `clean' mmake target.
Handle `.s' and `.pic_s' files as for the `.o' files
when using `--target asm'. There are no `.s' or `.pic_s'
files for nested modules.
scripts/Mmake.vars.in:
Set up the subdir variables for the timestamp files.
Mmakefile:
scripts/mercury_cleanup_install:
Save/restore the timestamp files and the `.used' files
across the library grade installation.
configure.in:
Remove the `.c_date' files for the `.c' files that
need to be rebuilt.
doc/user_guide.texi:
Document the new file extensions.
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.268
diff -u -u -r1.268 configure.in
--- configure.in 2001/07/03 02:43:57 1.268
+++ configure.in 2001/07/04 06:27:41
@@ -2834,55 +2834,67 @@
#-----------------------------------------------------------------------------#
MERCURY_CHECK_READLINE
#-----------------------------------------------------------------------------#
-to_keep=""
-to_delete=""
-if test "$BOOTSTRAP_MC" != "" ; then
- MERCURY_MSG("checking whether any C files need to be rebuilt...")
- for c_file in library/*.c compiler/*.c browser/*.c profiler/*.c deep_profiler/*.c \
- library/Mercury/cs/*.c compiler/Mercury/cs/*.c \
- browser/Mercury/cs/*.c profiler/Mercury/cs/*.c \
- deep_profiler/Mercury/cs/*.c
+
+check_c_files () {
+ c_dir=$1
+ c_date_dir=$2
+
+ for c_file in $c_dir/*.c
do
case $c_file in
*/'*.c')
;;
*/*_init.c)
- to_keep="$to_keep $c_file"
+ some_kept=true
;;
*)
sed -e '/END_OF_C_GRADE_INFO/q' < $c_file > confscratch
if grep "TAG_BITS=$mercury_cv_low_tag_bits" \
- confscratch > /dev/null 2>&1
+ confscratch > /dev/null 2>&1 \
+ && grep "UNBOXED_FLOAT=$mercury_cv_unboxed_floats" \
+ confscratch > /dev/null 2>&1
then
- if grep "UNBOXED_FLOAT=$mercury_cv_unboxed_floats" \
- confscratch > /dev/null 2>&1
- then
- to_keep="$to_keep $c_file"
- else
- to_delete="$to_delete $c_file"
- fi
+ some_kept=true
else
- to_delete="$to_delete $c_file"
+ c_date_file="$c_date_dir/`basename $c_file .c`.c_date"
+ to_delete="$to_delete $c_file $c_date_file"
fi
;;
esac
done
+}
+
+some_kept=false
+to_delete=""
+if test "$BOOTSTRAP_MC" != "" ; then
+ MERCURY_MSG("checking whether any C files need to be rebuilt...")
+ for directory in library compiler profiler deep_profiler
+ do
+ check_c_files $directory $directory
+ check_c_files $directory/Mercury/cs $directory/Mercury/c_dates
+ done
if test "$to_delete" = "" ; then
- if test "$to_keep" != "" ; then
+ case $some_kept in
+ true)
MERCURY_MSG("no - they are compatible with autoconfigured settings")
- else
+ ;;
+ false)
MERCURY_MSG("there are no existing Mercury-generated C files")
- fi
+ ;;
+ esac
else
- if test "$to_keep" != "" ; then
+ case $some_kept in
+ true)
MERCURY_MSG("the following C files must be rebuilt in a grade")
MERCURY_MSG("that is consistent with autoconfigured settings")
MERCURY_MSG("$to_delete")
- else
+ ;;
+ false)
MERCURY_MSG("all Mercury generated C files must be rebuilt")
MERCURY_MSG("in a grade that is consistent with the")
MERCURY_MSG("autoconfigured settings")
- fi
+ ;;
+ esac
MERCURY_MSG("installation may take longer than usual")
fi
rm -f confscratch $to_delete
--- mercury_compile.m 2001/07/04 06:31:05 1.3
+++ mercury_compile.m 2001/07/04 07:41:21
@@ -833,7 +833,7 @@
{ TargetFiles = [] }
;
module_name_to_file_name(ModuleName,
- TargetSuffix, no, FileName),
+ TargetSuffix, yes, FileName),
{ TargetFiles = [FileName] }
)
)
@@ -1067,7 +1067,7 @@
recompilation_usage__write_usage_file(HLDS,
NestedSubModules, MaybeTimestamps),
FindTimestampFiles(ModuleName, TimestampFiles),
- list__foldl(touch_file, TimestampFiles)
+ list__foldl(touch_datestamp, TimestampFiles)
;
% If the number of errors is > 0, make sure that
% the compiler exits with a non-zero exit
--- modules.m 2001/07/04 06:31:05 1.3
+++ modules.m 2001/07/04 13:49:34
@@ -577,12 +577,13 @@
:- pred touch_interface_datestamp(module_name, string, io__state, io__state).
:- mode touch_interface_datestamp(in, in, di, uo) is det.
- % touch_file(FileName).
+ % touch_datestamp(FileName).
%
- % Update the modification time for file `FileName'.
+ % Update the modification time for the given file,
+ % clobbering the contents of the file.
-:- pred touch_file(file_name, io__state, io__state).
-:- mode touch_file(in, di, uo) is det.
+:- pred touch_datestamp(file_name, io__state, io__state).
+:- mode touch_datestamp(in, di, uo) is det.
% update_interface(FileName)
%
@@ -1306,9 +1307,9 @@
touch_interface_datestamp(ModuleName, Ext) -->
module_name_to_file_name(ModuleName, Ext, yes, OutputFileName),
- touch_file(OutputFileName).
+ touch_datestamp(OutputFileName).
-touch_file(OutputFileName) -->
+touch_datestamp(OutputFileName) -->
globals__io_lookup_bool_option(verbose, Verbose),
maybe_write_string(Verbose, "% Touching `"),
maybe_write_string(Verbose, OutputFileName),
@@ -2874,24 +2875,120 @@
io__write_string(DepStream, "\n"),
io__write_string(DepStream, MakeVarName),
- io__write_string(DepStream, ".os = "),
- % for --target asm, we only generate separate object files
- % for top-level modules and separate sub-modules, not for
- % nested sub-modules.
+ io__write_string(DepStream, ".all_ss = "),
+ write_compact_dependencies_list(Modules, "$(ss_subdir)", ".s",
+ Basis, DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".all_pic_ss = "),
+ write_compact_dependencies_list(Modules, "$(ss_subdir)", ".pic_s",
+ Basis, DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".all_s_dates = "),
+ write_compact_dependencies_list(Modules, "$(s_dates_subdir)",
+ ".s_date", Basis, DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".all_pic_s_dates = "),
+ write_compact_dependencies_list(Modules, "$(pic_s_dates_subdir)",
+ ".pic_s_date", Basis, DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".all_os = "),
+ write_compact_dependencies_list(Modules, "$(os_subdir)", ".$O",
+ Basis, DepStream),
+ write_extra_link_dependencies_list(ExtraLinkObjs, ".$O", DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".all_pic_os = "),
+ write_compact_dependencies_list(Modules, "$(os_subdir)",
+ ".$(EXT_FOR_PIC_OBJECTS)", Basis, DepStream),
+ write_extra_link_dependencies_list(ExtraLinkObjs,
+ ".$(EXT_FOR_PIC_OBJECTS)", DepStream),
+ io__write_string(DepStream, "\n"),
+
{ IsNested = (pred(Mod::in) is semidet :-
get_submodule_kind(Mod, DepsMap) = nested_submodule) },
(
+ % For --target asm, we only generate separate object files
+ % for top-level modules and separate sub-modules, not for
+ % nested sub-modules.
{ Target = asm },
- { list__filter(IsNested, Modules, NestedModules, MainModules) },
+ { list__filter(IsNested, Modules,
+ NestedModules, MainModules) },
{ NestedModules \= [] }
->
- write_dependencies_list(MainModules, ".$O", DepStream)
- ;
- write_compact_dependencies_list(Modules, "$(os_subdir)",
- ".$O", Basis, DepStream)
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".ss = "),
+ write_dependencies_list(MainModules, ".s", DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".pic_ss = "),
+ write_dependencies_list(MainModules, ".pic_s", DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".s_dates = "),
+ write_dependencies_list(MainModules, ".s_date", DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".pic_s_dates = "),
+ write_dependencies_list(MainModules, ".pic_s_date", DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".os = "),
+ write_dependencies_list(MainModules, ".$O", DepStream),
+ write_extra_link_dependencies_list(ExtraLinkObjs, ".$O",
+ DepStream),
+ io__write_string(DepStream, "\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".pic_os = "),
+ write_dependencies_list(MainModules, ".$(EXT_FOR_PIC_OBJECTS)",
+ DepStream),
+ write_extra_link_dependencies_list(ExtraLinkObjs,
+ ".$(EXT_FOR_PIC_OBJECTS)", DepStream),
+ io__write_string(DepStream, "\n")
+ ;
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".ss = $("),
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".all_ss)\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".pic_ss = $("),
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".all_pic_ss)\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".s_dates = $("),
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".all_s_dates)\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".pic_s_dates = $("),
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".all_pic_s_dates)\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".os = $("),
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".all_os)\n"),
+
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".os = $("),
+ io__write_string(DepStream, MakeVarName),
+ io__write_string(DepStream, ".all_os)\n")
),
- write_extra_link_dependencies_list(ExtraLinkObjs, ".$O", DepStream),
- io__write_string(DepStream, "\n"),
%
% $(foo.cs_or_ss) contains the names of the generated intermediate
@@ -2910,7 +3007,6 @@
"endif\n\n"
]),
-
io__write_string(DepStream, MakeVarName),
io__write_string(DepStream, ".rlos = "),
write_compact_dependencies_list(Modules, "$(rlos_subdir)", ".rlo",
@@ -2930,15 +3026,6 @@
io__write_string(DepStream, "\n"),
io__write_string(DepStream, MakeVarName),
- io__write_string(DepStream, ".pic_os = "),
- write_compact_dependencies_list(Modules, "$(os_subdir)",
- ".$(EXT_FOR_PIC_OBJECTS)",
- Basis, DepStream),
- write_extra_link_dependencies_list(ExtraLinkObjs,
- ".$(EXT_FOR_PIC_OBJECTS)", DepStream),
- io__write_string(DepStream, "\n"),
-
- io__write_string(DepStream, MakeVarName),
io__write_string(DepStream, ".dirs = "),
write_compact_dependencies_list(Modules, "$(dirs_subdir)", ".dir",
Basis, DepStream),
@@ -2951,12 +3038,6 @@
io__write_string(DepStream, "\n"),
io__write_string(DepStream, MakeVarName),
- io__write_string(DepStream, ".ss = "),
- write_compact_dependencies_list(Modules, "$(ss_subdir)", ".s",
- Basis, DepStream),
- io__write_string(DepStream, "\n"),
-
- io__write_string(DepStream, MakeVarName),
io__write_string(DepStream, ".dates = "),
write_compact_dependencies_list(Modules, "$(dates_subdir)", ".date",
Basis, DepStream),
@@ -2999,18 +3080,6 @@
io__write_string(DepStream, "\n"),
io__write_string(DepStream, MakeVarName),
- io__write_string(DepStream, ".s_dates = "),
- write_compact_dependencies_list(Modules, "$(s_dates_subdir)",
- ".s_date", Basis, DepStream),
- io__write_string(DepStream, "\n"),
-
- io__write_string(DepStream, MakeVarName),
- io__write_string(DepStream, ".pic_s_dates = "),
- write_compact_dependencies_list(Modules, "$(pic_s_dates_subdir)",
- ".pic_s_date", Basis, DepStream),
- io__write_string(DepStream, "\n"),
-
- io__write_string(DepStream, MakeVarName),
io__write_string(DepStream, ".ds = "),
write_compact_dependencies_list(Modules, "$(ds_subdir)", ".d",
Basis, DepStream),
@@ -3402,14 +3471,16 @@
CleanTargetName, " :\n",
"\t-rm -rf $(", MakeVarName, ".dirs)\n",
"\t-rm -f $(", MakeVarName, ".cs) ", InitCFileName, "\n",
- "\t-rm -f $(", MakeVarName, ".ss) ", InitAsmFileName, "\n",
- "\t-rm -f $(", MakeVarName, ".os) ", InitObjFileName, "\n",
- "\t-rm -f $(", MakeVarName, ".pic_os) ", InitPicObjFileName,
- "\n",
+ "\t-rm -f $(", MakeVarName, ".all_ss) ", InitAsmFileName, "\n",
+ "\t-rm -f $(", MakeVarName, ".all_pic_ss) ",
+ InitAsmFileName, "\n",
+ "\t-rm -f $(", MakeVarName, ".all_os) ", InitObjFileName, "\n",
+ "\t-rm -f $(", MakeVarName, ".all_pic_os) ",
+ InitPicObjFileName, "\n",
"\t-rm -f $(", MakeVarName, ".c_dates)\n",
"\t-rm -f $(", MakeVarName, ".il_dates)\n",
- "\t-rm -f $(", MakeVarName, ".s_dates)\n",
- "\t-rm -f $(", MakeVarName, ".pic_s_dates)\n",
+ "\t-rm -f $(", MakeVarName, ".all_s_dates)\n",
+ "\t-rm -f $(", MakeVarName, ".all_pic_s_dates)\n",
"\t-rm -f $(", MakeVarName, ".useds)\n",
"\t-rm -f $(", MakeVarName, ".ils)\n",
"\t-rm -f $(", MakeVarName, ".profs)\n",
--- recompilation_check.m 2001/07/04 07:41:27 1.4
+++ recompilation_check.m 2001/07/04 07:41:42
@@ -102,7 +102,7 @@
(
{ Result = succeeded(Info4) },
FindTimestampFiles(ModuleName, TimestampFiles),
- list__foldl(touch_file, TimestampFiles),
+ list__foldl(touch_datestamp, TimestampFiles),
write_recompilation_message(
(pred(di, uo) is det -->
io__write_string("Not recompiling module "),
--------------------------------------------------------------------------
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