Put .module_dep files grade-specific dirs.

compiler/file_names.m:
    Reclassify .module_dep files as being put into grade-specific
    subdirs in the presence of --use-grade-subdirs.

    Document why .err_date files also belong in grade-specific subdirs.

    Document why .prof files do NOT belong in grade-specific subdirs.

    Fix some typos.

compiler/generate_mmakefile_fragments.m:
compiler/make.get_module_dep_info.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/mercury_compile_main.m:
    Conform to the changes above.
This commit is contained in:
Zoltan Somogyi
2024-08-04 12:41:25 +02:00
parent 96a932107b
commit b296fac67d
5 changed files with 52 additions and 39 deletions

View File

@@ -298,19 +298,20 @@
; ext_cur_ngs_mf_d % ".d"
; ext_cur_ngs_mf_dv % ".dv"
; ext_cur_ngs_mf_dep % ".dep"
% Misc extensions.
; ext_cur_ngs_misc_module_dep % ".module_dep"
% XXX DODGY What is the correctness argument for making this
% a NON-grade-specific extension? If *anything* in a .module_dep
% file can *ever* be grade dependent, this should be a
% grade-specific extension.
; ext_cur_ngs_misc_prof. % ".prof"
% XXX DODGY Given that different profiling grades generate
% different profiles (specifically, they produce different subsets
% of the whole set of kinds of info that the non-deep profiler can
% generate), shouldn't this be a grade-specific extension?
% XXX zs and juliensf agree on this.
% .prof files contain the edges in the call graph of a module,
% and are intended to be used by the mprof profiler. Changing
% from one grade to another can theoretically add edges to
% or delete edges from this call graph, by replacing a foreign_proc
% (which cannot have *visible* calls to other Mercury predicates)
% with Mercury code (which can have such cals), or vice versa.
% However, the use of mprof implies targeting C using the LLDS
% backend, and two grades that both do that are guaranteed to pick
% the same definition for every predicate. This guarantees that
% every .prof file will contain the same call graph, even if
% their full grades differ. (For example, one could be none.prof.gc
% and one could be asm_fast.gc.prof.tr.) This is why it would not
% make sense to put .prof files into a grade-specific subdirectory.
:- type ext_cur_gs
% Executables generated for a whole program.
@@ -342,7 +343,7 @@
% ; ext_cur_gs_lib_so % ".so"
% NOTE Neither ext_cur_gs_lib_lib nor ext_cur_gs_lib_so are
% ever referred to by that name. All references to files with
% those extensions use ext_cur_gs_lib_lib_opt and
% .lib and .so extensions use ext_cur_gs_lib_lib_opt and
% ext_cur_gs_lib_sh_lib_opt.
; ext_cur_gs_lib_dollar_a % ".$A"
; ext_cur_gs_lib_archive % ".a"
@@ -356,7 +357,7 @@
% Timestamp files showing when their corresponding .*opt files
% were last checked.
---> ext_cur_ngs_gs_opt_date_plain % ".optdate"
; ext_cur_ngs_gs_opt_date_trans % ".trace_opt_date"
; ext_cur_ngs_gs_opt_date_trans % ".trans_opt_date"
% C and C# source files generated by the Mercury compiler.
; ext_cur_ngs_gs_target_c % ".c"
@@ -404,6 +405,16 @@
% Misc extensions.
; ext_cur_ngs_gs_misc_err_date % ".err_date"
% If you recompile a module in a different grade, the contents
% of the .err file may change, for example because one grade
% satisfies the requirements of a require_feature_set declaration
% and the other does not.
% Misc extensions.
; ext_cur_ngs_gs_misc_module_dep % ".module_dep"
% There is no known argument for the proposition that the
% contents of a .module_dep file is grade-independent.
% Therefore the safe thing to do is to make it grade-specific.
; ext_cur_ngs_gs_misc_used % ".used"
; ext_cur_ngs_gs_misc_track_flags. % ".track_flags"
@@ -792,8 +803,6 @@ ext_cur_ngs_extension_dir(Ext, Str, Dir) :-
% rule is intentional, though I (zs) don't know the full reason.
; Ext = ext_cur_ngs_mf_dv, Str = ".dv", Dir = "deps"
; Ext = ext_cur_ngs_mf_dep, Str = ".dep", Dir = "deps"
; Ext = ext_cur_ngs_misc_module_dep,
Str = ".module_dep",Dir = "module_deps"
; Ext = ext_cur_ngs_misc_prof, Str = ".prof", Dir = "profs"
).
@@ -802,21 +811,21 @@ ext_cur_ngs_extension_dir(Ext, Str, Dir) :-
ext_cur_gs_extension_dir(Globals, Ext, Str, Dir) :-
% Launcher scripts go in the `bin' subdirectory.
( Ext = ext_cur_gs_exec_noext, Str = "", Dir = "bin"
; Ext = ext_cur_gs_exec_exe, Str = ".exe", Dir = "bin"
; Ext = ext_cur_gs_exec_bat, Str = ".bat", Dir = "bin"
( Ext = ext_cur_gs_exec_noext, Str = "", Dir = "bin"
; Ext = ext_cur_gs_exec_exe, Str = ".exe", Dir = "bin"
; Ext = ext_cur_gs_exec_bat, Str = ".bat", Dir = "bin"
; Ext = ext_cur_gs_exec_exec_opt,
globals.lookup_string_option(Globals, executable_file_extension, Str),
Dir = "bin"
; Ext = ext_cur_gs_lib_dollar_efsl,
Str = ".$(EXT_FOR_SHARED_LIB)", Dir = "lib"
% ; Ext = ext_cur_gs_lib_lib, Str = ".lib", Dir = "lib"
% ; Ext = ext_cur_gs_lib_so, Str = ".so", Dir = "lib"
; Ext = ext_cur_gs_lib_dollar_a, Str = ".$A", Dir = "lib"
; Ext = ext_cur_gs_lib_archive, Str = ".a", Dir = "lib"
; Ext = ext_cur_gs_lib_dll, Str = ".dll", Dir = "lib"
; Ext = ext_cur_gs_lib_init, Str = ".init", Dir = "inits"
; Ext = ext_cur_gs_lib_jar, Str = ".jar", Dir = "lib"
% ; Ext = ext_cur_gs_lib_lib, Str = ".lib", Dir = "lib"
% ; Ext = ext_cur_gs_lib_so, Str = ".so", Dir = "lib"
; Ext = ext_cur_gs_lib_dollar_a, Str = ".$A", Dir = "lib"
; Ext = ext_cur_gs_lib_archive, Str = ".a", Dir = "lib"
; Ext = ext_cur_gs_lib_dll, Str = ".dll", Dir = "lib"
; Ext = ext_cur_gs_lib_init, Str = ".init", Dir = "inits"
; Ext = ext_cur_gs_lib_jar, Str = ".jar", Dir = "lib"
; Ext = ext_cur_gs_lib_lib_opt,
globals.lookup_string_option(Globals, library_extension, Str),
Dir = "lib"
@@ -873,15 +882,17 @@ ext_cur_ngs_gs_extension_dir(Globals, Ext, Str, Dir) :-
Str = "_init" ++ Str0,
Dir = "os"
; Ext = ext_cur_ngs_gs_an_ds_date,
Str = ".analysis_date", Dir = "analysis_dates"
Str = ".analysis_date", Dir = "analysis_dates"
; Ext = ext_cur_ngs_gs_an_ds_status,
Str = ".analysis_status", Dir = "analysis_statuss"
Str = ".analysis_status", Dir = "analysis_statuss"
; Ext = ext_cur_ngs_gs_misc_err_date,
Str = ".err_date", Dir = "err_dates"
Str = ".err_date", Dir = "err_dates"
; Ext = ext_cur_ngs_gs_misc_module_dep,
Str = ".module_dep", Dir = "module_deps"
; Ext = ext_cur_ngs_gs_misc_used,
Str = ".used", Dir = "useds"
Str = ".used", Dir = "useds"
; Ext = ext_cur_ngs_gs_misc_track_flags,
Str = ".track_flags", Dir = "track_flags"
Str = ".track_flags", Dir = "track_flags"
).
:- pred ext_cur_ngs_gs_err_extension_dir(ext_cur_ngs_gs_err::in,

View File

@@ -680,7 +680,7 @@ construct_module_dep_fragment(Globals, ModuleName, CFileName,
ext_cur_ngs_gs_java(ext_cur_ngs_gs_java_java),
ModuleName, JavaFileName, !Cache, !IO),
make_module_file_name(Globals, $pred,
ext_cur_ngs(ext_cur_ngs_misc_module_dep),
ext_cur_ngs_gs(ext_cur_ngs_gs_misc_module_dep),
ModuleName, ModuleDepFileName, !Cache, !IO),
MmakeFragmentModuleDep = mmf_conditional_entry(
mmake_cond_grade_has_component("java"),
@@ -1221,7 +1221,7 @@ generate_dv_file(Globals, SourceFileName, ModuleName, DepsMap,
[s(ModuleMakeVarName)])),
ModuleDepFileExtStr = extension_to_string(Globals,
ext_cur_ngs(ext_cur_ngs_misc_module_dep)),
ext_cur_ngs_gs(ext_cur_ngs_gs_misc_module_dep)),
MmakeVarModuleDeps = mmake_var_defn(ModuleMakeVarName ++ ".module_deps",
string.format("$(%s.mods:%%=$(module_deps_subdir)%%%s)",
[s(ModuleMakeVarName), s(ModuleDepFileExtStr)])),

View File

@@ -156,7 +156,7 @@ do_get_maybe_module_dep_info(ProgressStream, Globals, RebuildModuleDeps,
ModuleName, !:MaybeModuleDepInfo, !Info, !IO) :-
globals.lookup_accumulating_option(Globals, search_directories,
SearchDirs),
ModuleDepExt = ext_cur_ngs(ext_cur_ngs_misc_module_dep),
ModuleDepExt = ext_cur_ngs_gs(ext_cur_ngs_gs_misc_module_dep),
module_name_to_file_name(Globals, $pred, ModuleDepExt,
ModuleName, DepFileName),
get_file_timestamp(SearchDirs, DepFileName, MaybeDepFileTimestamp,
@@ -310,7 +310,8 @@ do_get_maybe_module_dep_info(ProgressStream, Globals, RebuildModuleDeps,
find_and_read_module_dep_file(ProgressStream, Globals, RebuildModuleDeps,
SearchDirs, ModuleName, !Info, !IO) :-
module_name_to_search_file_name(Globals, $pred,
ext_cur_ngs(ext_cur_ngs_misc_module_dep), ModuleName, DepFileName),
ext_cur_ngs_gs(ext_cur_ngs_gs_misc_module_dep),
ModuleName, DepFileName),
search_for_file_returning_dir_and_contents(SearchDirs, DepFileName,
MaybeDirAndContents, !IO),
(
@@ -730,7 +731,8 @@ cleanup_module_dep_files(ProgressStream, Globals, ModuleNames, !Info, !IO) :-
cleanup_module_dep_file(ProgressStream, Globals, ModuleName, !Info, !IO) :-
remove_module_file_for_make(ProgressStream, Globals, verbose_make,
ModuleName, ext_cur_ngs(ext_cur_ngs_misc_module_dep), !Info, !IO).
ModuleName, ext_cur_ngs_gs(ext_cur_ngs_gs_misc_module_dep),
!Info, !IO).
:- pred maybe_write_importing_module(io.text_output_stream::in,
module_name::in, maybe(import_or_include)::in, io::di, io::uo) is det.

View File

@@ -134,7 +134,7 @@ do_write_module_dep_file(ProgressStream, Globals, BurdenedModule, !IO) :-
BurdenedModule = burdened_module(Baggage, ParseTreeModuleSrc),
ModuleName = ParseTreeModuleSrc ^ ptms_module_name,
module_name_to_file_name_create_dirs(Globals, $pred,
ext_cur_ngs(ext_cur_ngs_misc_module_dep),
ext_cur_ngs_gs(ext_cur_ngs_gs_misc_module_dep),
ModuleName, ProgDepFile, !IO),
io.open_output(ProgDepFile, ProgDepResult, !IO),
(

View File

@@ -1735,7 +1735,7 @@ install_ints_and_headers(ProgressStream, Globals, SubdirLinkSucceeded,
ExtExtDirs = [{ext_cur_ngs(ext_cur_ngs_int_int1), "ints"},
{ext_cur_ngs(ext_cur_ngs_int_int2), "int2s"},
{ext_cur_ngs(ext_cur_ngs_int_int3), "int3s"},
{ext_cur_ngs(ext_cur_ngs_misc_module_dep), "module_deps"}
{ext_cur_ngs_gs(ext_cur_ngs_gs_misc_module_dep), "module_deps"}
| ExtExtDirs1],
globals.lookup_string_option(Globals, install_prefix, Prefix),
LibDir = Prefix/"lib"/"mercury",
@@ -2449,7 +2449,7 @@ make_module_realclean(ProgressStream, Globals, ModuleName, !Info, !IO) :-
very_verbose, ModuleName),
Targets, !Info, !IO),
remove_module_file_for_make(ProgressStream, Globals, very_verbose,
ModuleName, ext_cur_ngs(ext_cur_ngs_misc_module_dep),
ModuleName, ext_cur_ngs_gs(ext_cur_ngs_gs_misc_module_dep),
!Info, !IO),
remove_module_file_for_make(ProgressStream, Globals, very_verbose,
ModuleName, ext_cur_ngs_gs_max_ngs(ext_cur_ngs_gs_max_ngs_an_imdg),