Stop using module_dep_infos in computing filenames.

compiler/make.file_names.m:
    Delete module_target_file_to_file_name_maybe_search_module_dep,
    which differed from module_target_to_maybe_for_search_file_name
    only in that took the filenames of .m files from the module_dep_infos
    of already-read-in modules, rather than from the filenames computed from
    the module names. Ever since we required that either

    - the name of a file containing a module be derived directly from
      the module name, or
    - the name of a file containing a module be recorded in Mercury.modules
      files using commands such as mmc -f *.m,

    we only LOOK for modules in files that fit one of these two criteria,
    so it should not be possible for the module_dep_info to record
    any filename that differs from what would be returned by
    module_target_to_maybe_for_search_file_name.

compiler/make.module_target.m:
compiler/make.timestamp.m:
    Conform to the change above.
This commit is contained in:
Zoltan Somogyi
2023-11-13 22:17:15 +11:00
parent 7bb0bc4941
commit 764eab72ae
3 changed files with 5 additions and 93 deletions

View File

@@ -35,23 +35,6 @@
:- pred dependency_file_to_file_name(globals::in, dependency_file::in,
string::out, io::di, io::uo) is det.
% module_target_file_to_file_name_maybe_search_module_dep(ProgressStream,
% Globals, From, Search, TargetFile, FileName, !IO):
%
% Compute a file name for the given target file.
%
% This predicate uses the same algorithm as module_target_file_to_file_name
% for almost all target types. The one exception is module_target_source,
% for which it tries to get the filename from the module's module_dep_info
% structure, if it exists.
%
% XXX This special treatment of module_target_source is probably a bug.
%
:- pred module_target_file_to_file_name_maybe_search_module_dep(
io.text_output_stream::in, globals::in, string::in, maybe_for_search::in,
target_file::in, file_name::out,
make_info::in, make_info::out, io::di, io::uo) is det.
% Return the file name for the given target_file. The I/O state pair
% may be needed to find this file name.
%
@@ -81,8 +64,6 @@
:- import_module backend_libs.
:- import_module backend_libs.compile_target_code.
:- import_module make.get_module_dep_info.
:- import_module parse_tree.module_dep_info.
:- import_module parse_tree.prog_foreign.
%---------------------------------------------------------------------------%
@@ -96,29 +77,6 @@ dependency_file_to_file_name(Globals, DepFile, FileName, !IO) :-
DepFile = dep_file(FileName)
).
module_target_file_to_file_name_maybe_search_module_dep(ProgressStream,
Globals, From, ForSearch, TargetFile, FileName, !Info, !IO) :-
TargetFile = target_file(ModuleName, TargetType),
( if TargetType = module_target_source then
% In some cases the module name won't match the file name
% (module mdb.parse might be in parse.m or mdb.m), so we need to
% look up the file name here.
get_maybe_module_dep_info(ProgressStream, Globals,
ModuleName, MaybeModuleDepInfo, !Info, !IO),
(
MaybeModuleDepInfo = some_module_dep_info(ModuleDepInfo),
module_dep_info_get_source_file_name(ModuleDepInfo, FileName)
;
MaybeModuleDepInfo = no_module_dep_info,
% Something has gone wrong generating the dependencies,
% so just take a punt (which probably won't work).
module_name_to_source_file_name(ModuleName, FileName, !IO)
)
else
module_target_to_maybe_for_search_file_name(Globals, From, ForSearch,
TargetType, ModuleName, FileName, !IO)
).
module_target_file_to_file_name(Globals, From, TargetFile, FileName, !IO) :-
TargetFile = target_file(ModuleName, TargetType),
module_target_to_file_name(Globals, From, TargetType, ModuleName,

View File

@@ -372,48 +372,7 @@ make_dependency_files(ProgressStream, Globals, TargetFile, TargetFileName,
find_error_or_oldest_ok_timestamp(
TouchedTargetFileTimestamps ++ TouchedFileTimestamps,
MaybeOldestTimestamp),
% Our caller computes TargetFileName using the call
%
% module_target_file_to_file_name(Globals, $pred, TargetFile,
% TargetFileName, !IO)
%
% module_target_file_to_file_name_maybe_module_dep and
% module_target_file_to_file_name both just call
% module_name_to_file_name for *most*, but not *all*
% target file types. There is one exception:
% module_target_source. For this target type,
% one of the following three must hold:
%
% - the different code paths in the above two predicates
% may be equivalent even though they do not seem to be,
% in which case one of those predicates is redundant;
%
% - this code point cannot be reached with this target file
% type, a proposition for which I (zs) see no evidence, or
%
% - the call to module_target_file_to_file_name_maybe_
% _search_maybe_module_dep here, instead of just
% module_target_file_to_file_name, is, and always has been,
% a BUG.
%
% The fact that a hlc.gc bootcheck does not cause the
% call to expect below to throw an exception seems to argue
% against the last alternative above.
%
% It is also possible that the correct answer *was* the
% last alternative until we started requiring "mmc -f *.m"
% if any module was stored in a nonstandard filename,
% but now that we do require that, the correct answer has
% become the first alternative. If this is the case, then
% calling module_target_file_to_file_name here would be
% equivalent but simpler.
module_target_file_to_file_name_maybe_search_module_dep(
ProgressStream, Globals, $pred, not_for_search,
TargetFile, TargetFileNameB, !Info, !IO),
expect(unify(TargetFileName, TargetFileNameB), $pred,
"TargetFileName mismatch"),
check_dependencies(ProgressStream, Globals, TargetFileNameB,
check_dependencies(ProgressStream, Globals, TargetFileName,
MaybeOldestTimestamp, MakeDepsSucceeded, DepFilesToMake,
DepsResult, !Info, !IO)
)
@@ -878,12 +837,8 @@ record_made_target_given_maybe_touched_files(ProgressStream, Globals,
list.foldl(update_target_status(TargetStatus), TouchedTargetFiles, !Info),
list.map_foldl2(
% XXX I (zs) think that we should pass a closure containing
% just plain old module_target_file_to_file_name.
module_target_file_to_file_name_maybe_search_module_dep(ProgressStream,
Globals, $pred, not_for_search),
TouchedTargetFiles, TouchedTargetFileNames, !Info, !IO),
list.map_foldl(module_target_file_to_file_name(Globals, $pred),
TouchedTargetFiles, TouchedTargetFileNames, !IO),
some [!FileTimestamps] (
!:FileTimestamps = make_info_get_file_timestamps(!.Info),

View File

@@ -168,9 +168,8 @@ get_target_timestamp(ProgressStream, Globals, Search, TargetFile,
MaybeTimestamp = ok(Timestamp)
else
ForSearch = maybe_search_to_maybe_for_search(Search),
module_target_file_to_file_name_maybe_search_module_dep(
ProgressStream, Globals, $pred, ForSearch,
TargetFile, FileName, !Info, !IO),
module_target_to_maybe_for_search_file_name(Globals, $pred,
ForSearch, TargetType, ModuleName, FileName, !IO),
get_target_timestamp_2(ProgressStream, Globals,
Search, TargetFile, FileName, MaybeTimestamp, !Info, !IO),
(