[m-rev.] for review: fix mantis bug #573

Peter Wang novalazy at gmail.com
Fri Feb 23 15:31:01 AEDT 2024


On Fri, 23 Feb 2024 05:02:09 +1100 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> For review by Peter.
> 
> Zoltan.

> Update .optdate/.trans_opt_date files when needed.
> 
> compiler/mercury_compile_front_end.m:
>     Update a module's .optdate file when we construct a .opt file,
>     even if we don't actually update the .opt file, because its current
>     content is what we *would* write. Mantis bug #573 was caused
>     by the lack of this update.
> 
> compiler/mercury_compile_middle_passes.m:
>     Fix the same bug for .trans_opt_date files.
> 
> The next two changes are nits I noticed while looking for the bug.
> 
> compiler/make.check_up_to_date.m:
>     Factor out some common code.
> 
> compiler/make.module_target.m:
>     Clarify an error message.

> diff --git a/compiler/mercury_compile_front_end.m b/compiler/mercury_compile_front_end.m
> index 8f386cbdc..fa18bcbb6 100644
> --- a/compiler/mercury_compile_front_end.m
> +++ b/compiler/mercury_compile_front_end.m
> @@ -596,10 +596,6 @@ create_and_write_opt_file(ProgressStream, ErrorStream, IntermodAnalysis,
>              io.write_string(OptStream, OptFileStr, !IO),
>              io.close_output(OptStream, !IO),
>  
> -            OptDateExt = ext_cur_ngs_gs(ext_cur_ngs_gs_opt_date_plain),
> -            touch_module_ext_datestamp(Globals, ProgressStream,
> -                ModuleName, OptDateExt, _TouchSucceeded, !IO),
> -
>              globals.lookup_bool_option(Globals, experiment5, Experiment5),
>              (
>                  Experiment5 = no
> @@ -622,7 +618,13 @@ create_and_write_opt_file(ProgressStream, ErrorStream, IntermodAnalysis,
>                  )
>              )
>          )
> -    ).
> +    ),
> +
> +    % We update the .optdate file's timestamp whether or not
> +    % we wrote out a new version of the .opt file.
> +    OptDateExt = ext_cur_ngs_gs(ext_cur_ngs_gs_opt_date_plain),
> +    touch_module_ext_datestamp(Globals, ProgressStream,
> +        ModuleName, OptDateExt, _TouchSucceeded, !IO).
>  

Hmm, should we avoid touching the .optdate or .trans_opt_date
if we fail to open the .opt or .trans_opt file for output?

Other than that, the diff looks fine. Thanks.

Peter


More information about the reviews mailing list