... because they are almost always passed together, and grouping them
makes this clear. Also, code with shorter argument lists is more readable.
compiler/options_file.m:
Define the types of the collective structures. Defined them here
because one of them is defined here, and all the others are
lists of strings.
compiler/make.make_info.m:
Store one of its collective structures instead of its components.
compiler/make.build.m:
compiler/make.get_module_dep_info.m:
compiler/make.library_install.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/mercury_compile_args.m:
compiler/mercury_compile_main.m:
Conform to the changes above.
compiler/make.build.m:
compiler/make.check_up_to_date.m:
compiler/make.file_names.m:
compiler/make.find_local_modules.m:
compiler/make.hash.m:
compiler/make.index_set.m:
compiler/make.library_install.m:
compiler/make.make_info.m:
compiler/make.module_target.m:
compiler/make.prereqs.m:
compiler/make.prereqs_cache.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
compiler/make.top_level.m:
compiler/make.util.m:
Perform the above rename, and similar ones as well.
Replace the dep_target/dep_file distinction, which was misleading,
with the merc_target/non_merc_target distinction. (Both name files
that can be prerequisites, but the Mercury-related files can be built
by mmc --make.)
In one case, make unnecessarily-exported type definitions private.
compiler/mercury_compile_make_hlds.m:
compiler/mmakefiles.m:
Perform similar renames.
compiler/make.prereqs.m:
compiler/make.prereqs_cache.m:
compiler/make.index_set.m:
Rename make.dependencies.m to make.prereqs.m;
rename make.deps_cache.m to make.prereqs_cache.m; and
rename make.deps_set.m to make.index_set.m.
We have several kinds of dependencies in the Mercury system;
the renames make clear that these modules deal with prerequisites
of make targets. The reason why the word "prereq" is not part of the
new name of the third module is that this module's functionality is
generic; it does not care whether the modules and files it deals with
(representing them as index values in sets) are prerequisites or not.
compiler/make.m:
compiler/notes/compiler_design.html:
Rename the above modules.
compiler/make.find_local_modules.m:
compiler/make.make_info.m:
compiler/make.module_target.m:
compiler/make.top_level.m:
compiler/mercury_compile_main.m:
Conform to the changes above.
An unrelated change that ought to have been committed separately
but is now too hard to disentangle from the change above:
Stop creating .err.tmp files.
compiler/make.build.m:
When we start to build a module target, always direct diagnostic
outout to the module's .err file. Do this whether the module
has a .err file already or not, since we want to overwrite any
existing .err file anyway.
Simplify the interface of the affected predicates by deleting
arguments that are no longer needed.
compiler/make.make_info.m:
Stop keeping track of which modules have had .err files
created for them already, since we no longer need this info.
compiler/make.get_module_dep_info.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changed argument lists in make.build.m.
Give a predicate a more descriptive name.
There are currently two separate predicates used for invoking the C# compiler.
One is in link_target_code and is used to create executables and libraries
in the C# grade. The other is compile_target_code and was previously used
by the old .NET backend to compile additional C# source files. It is currently
plugged into the code that compiles the source files used for fact tables, but
as they are not supported by the C# backed, it has never been used in practice
for this purpose.
Delete the code for invoking the C# compiler in compile_target_code, since it
will have no users after this diff and is almost certainly affected by bitrot
at this point.
compiler/compile_target_code.m:
Delete the compile_csharp_file/8 predicate. It is unused.
compiler/make.module_target.m:
Abort if we are requested to build a Java or C# foreign code file.
The only thing that currently makes such requests is compilation of
fact tables and neither the Java or C# backend supports those.
Add an explanation of an issue in an XXX.
compiler/link_target_code.m:
Add an XXX about the MS C# compiler that needs to be investigated.
compiler/link_target_code.m:
Include suffixes such as "_for_c" in the names of the predicates
of this module to indicate the set of target languages whose linking
they are involved in.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile_main.m:
Conform to the changes above.
compiler/add_heap_ops.m:
compiler/check_import_accessibility.m:
compiler/comp_unit_interface.m:
compiler/convert_import_use.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/distance_granularity.m:
compiler/equiv_type.m:
compiler/generate_dep_d_files.m:
compiler/generate_mmakefile_fragments.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/higher_order.specialize_unify_compare.m:
compiler/jumpopt.m:
compiler/layout_out.m:
compiler/lco.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.get_module_dep_info.m:
compiler/make.library_install.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/make_hlds_passes.m:
compiler/make_module_file_names.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_disj_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_lookup_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_test.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_target_util.m:
compiler/module_cmds.m:
compiler/opt_deps_spec.m:
compiler/optimize.m:
compiler/parse_dcg_goal.m:
compiler/parse_goal.m:
compiler/parse_item.m:
compiler/parse_module.m:
compiler/parse_string_format.m:
compiler/proc_gen.m:
compiler/prop_mode_constraints.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.region_analysis.m:
compiler/rbmm.region_transformation.m:
compiler/simplify_goal_disj.m:
compiler/ssdebug.m:
compiler/stack_opt.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/term_constr_build.m:
compiler/trace_gen.m:
compiler/tupling.m:
compiler/untupling.m:
compiler/write_deps_file.m:
deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/html_format.m:
deep_profiler/startup.m:
profiler/mercury_profile.m:
profiler/propagate.m:
Act on the new warnings. In a few cases, conform to the changes
resulting from acting on the warnings in other modules.
browser/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
ssdb/Mercury.options:
Specify options for disabling the new warnings for modules
where we (probably) won't want them.
configure.ac:
Require the installed compiler to understand the options that
we now reference in the Mercury.options files above.
tests/debugger/tailrec1.exp:
Expect variable names for the middle versions of state vars
using the new naming scheme.
tests/invalid/Mercury.options:
Fix references to obsolete test names.
tests/warnings/Mercury.options:
Avoid a test failure with intermodule optimization.
compiler/compile_target_code.m:
compiler/link_target_code.m:
Move the parts of compile_target_code.m that concern linking
to the new module link_target_code.m. Leave the parts concerned
with just compilation.
The new module link_target_code.m imports compile_target_code.m,
but not vice versa. To make this possible, get compile_target_code.m
to decide PIC vs non-PIC for executables, since that info is needed
during non-linking tasks, while making that decision for linking tasks
in link_target_code.m.
Reorder the contents of link_target_code.m to put related predicates
next to each other, and to put these groups of related predicates
into a meaningful order.
Inline a tiny predicate at its only call site. Replace a boolean argument
with a value of a bespoke type.
compiler/backend_libs.m:
compiler/notes/compiler_design.html:
Include and document the new module.
compiler/file_util.m:
Move a predicate here from compile_target_code.m. It is needed
by both compile_target_code.m and link_target_code.m, but it would
feel wrong for it to be exported by compile_target_code.m. It looks
much better for it to be exported by file_util.m.
compiler/make.program_target.m:
Conform to the changes above.
Move a predicate next to its only caller.
Add an XXX.
compiler/make.clean.m:
compiler/make.make_info.m:
compiler/make.module_target.m:
compiler/make.top_level.m:
compiler/mercury_compile_augment.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
Conform to the changes above.
compiler/compile_target_code.m:
Give the two main predicates that do linking more descriptive names.
Expand the comment on one, and add a comment on the other.
Make one of these predicates take as input a list of module names,
not a list of file names. Previously, we converted module names to
file names, passed them to this predicate, which then converted them
*back* to module names. The new code, by avoiding unneeded
transformations, also avoids the possibility of callers passing
file names that did not start out as module names, which therefore
cannot be *meaningfully* converted back to module names.
Move the globals argument of a predicate to one of its usual places,
because the reason for its being supplied late does not apply anymore.
Consistently use a single variable names to describe linked_target_types;
some of the old variable names were misleading.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/mercury_compile_augment.m:
compiler/mercury_compile_main.m:
Conform to the changes above.
The previous change to how detecting stdlib grade works exposed
an ordering problem. The base of the problem was that
- we had to detect the grades in which the standard library is installed
*first*, so that
- we could convert this set to a sequence of compiler-generated
--libgrade options, so they could then be updated by
- later, user-specified --libgrade options.
All this happened before we constructed the first globals structure. The
problem is that the code in handle_options.m that finds out what stdlib
location we want to use *needs* the first globals structure. The result
of this computation worked correctly only if the initial, effectively guessed
stdlib location we used in step 1 above happened to be the final chosen
stdlib location.
The root cause of the problem was the use of --libgrade options
for two related but nevertheless conceptually separate things:
- the set grades in which the Mercury standard libray is installed
in its chosen location, and
- the set of grade in which the user wants to install his/her libraries.
The latter defaults to the former, but user options can tell the compiler
to deviate from that default.
The main part of the fix is to use --libgrade options only for the
second notion (which it is already named after), and to store the
set of stdlib grades not in option values at all, but in a new field
in the globals structure. This field can then be filled with meaningful data
*after* we have chosen the location of the Mercury stdlib.
The main complication with using this approach is that mmc --make
currently rebuilds the globals structure from scratch before building
each target. (I am not sure whether this is necessary, but it does seem
a nontrivial thing to change.) Doing this naively would cause us to detect
the stdlib's grades once per target, which is obviously wasteful.
The old code handled this by adding a --libgrade option for each stdlib grade
to the list of options we build each target with; the new code passes
the value in the new globals field instead.
compiler/options.m:
doc/user_guide.texi:
Change the --detect-libgrades option name to --detect-stdlib-grades.
Unlike the old name, the new name is not misleading. Leave the old
name as a synonym, for backward compatibility.
XXX Do we need backward compatibility in such a rarely-used option?
NEWS:
Document the new option name, XXX as either a rename or a new synonym.
compiler/options.m:
Set the initial value of the libgrades option to "stdlib".
compiler/handle_options.m:
If the initial value of the libgrades option to "stdlib", then replace
that value with the set of detected stdlib grades. Do this after either
- detecting those grades in the chosen stdlib dir, or
- just recalling the result of that computation, if it has been done
before.
Thread a variable through the code of this module that specifies
whether we have does this before.
compiler/globals.m:
Add a slot to the globals structure where handle_options.m can record
the result of detecting stdlib grades.
compiler/mercury_compile_args.m:
compiler/mercury_compile_main.m:
Stop passing around stdlib grade flags in code that we execute
before we construct the first globals, since we now do this job
after we construct the first globals.
Delete the code in mercury_compile_args.m that used to do this job;
its updated version is now in handle_options.m.
Change the code in mercury_compile_main.m that implements the
--output-stdlib-grade option. Instead of invoking check_libgrades.m,
we can now just look up the result we got when handle_options.m
did that same invocation.
compiler/check_libgrades.m:
Make the code detecting stdlib grades take a globals as an argument,
since it is now invoked when we *have* a globals structure.
compiler/compute_grade.m:
Give a predicate a more descriptive name.
Add an XXX.
compiler/make.make_info.m:
Replace the field of the make_info that contained the set of stdlib grades
in the form of an option list with a field that contains that same info
as a bespoke structure.
compiler/make.build.m:
compiler/make.get_module_dep_info.m:
compiler/make.library_install.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
Conform to the changes above.
compiler/options_file.m:
Change the names of types, function symbols, predicates and variables
to reflect the fact that the values of the variables come from
*either* environment variables *or* options files.
Change a misleading "_type" suffix on a type name.
compiler/check_libgrades.m:
compiler/make.build.m:
compiler/make.get_module_dep_info.m:
compiler/make.library_install.m:
compiler/make.make_info.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/mercury_compile_main.m:
Conform to the changes above.
... (mostly) in one place.
compiler/file_names.m:
Change the module_name_to_search_file_name predicate to
- take as input a specification of where the caller intends to search for
the file name returned by this predicate (the new search_which_dirs
input argument),
- use insts to check, at compile time, whether this specification
is compatible with the extension of the file (by intentionally causing
the call to have a mode error if they are not compatible),
- if they are compatible, return a "search authorization" that contains
the information in the search_which_dirs argument in a form that
should be known *only* to file_names.m (which issues the authorization)
and find_module.m (which acts on such authorizations).
To make the above possible, move the search_which_dirs type here
from find_module.m, move many insts on the ext type here from several
other modules, and add some new insts on that type.
Improve documentation.
compiler/find_module.m:
Delete the search_which_dirs type that this diff moves to file_names.m.
Add in its place the search_auth_dirs type, which represents search
authorizations. Make all predicates in this module take search
authorizations instead of search specifications as inputs.
The difference is that only the module_name_to_search_file_name
predicate in file_names.m, and a few functions in this module,
generate search authorizations that involve references to the
various options containing lists of directory names.
compiler/make.file_names.m:
Replace predicates that take a maybe_for_search argument with two
predicates each, one for not for search and one for search. This is
because the for search versions now take two extra arguments:
a search_which_dirs input argument and a search_auth_dirs output argument.
Factor out the common code from the resulting predicate pairs
where this is worth while.
Improve documentation.
compiler/make.timestamp.m:
Replace predicates that take a maybe_for_search argument with two
predicates each, one for not for search and one for search. This is
because the for search versions and the not_for_search versions
now call different predicates, and two separate predicates ends up
being less code that tests around all the calls.
Factor out the common code from the resulting predicate pairs
where this is worth while.
Delete the code that specifies the default list of directories
in which to search for files with given extensions, since it is now
in file_names.m (in a modified form).
compiler/analysis.framework.m:
Delete the inst definitions that this diff moves to file_names.m.
compiler/compile_target_code.m:
compiler/file_kind.m:
Provide more precise insts for the outputs of some predicates.
This is because some of their callers need those insts to satisfy
the new requirements of module_name_to_search_file_name.
compiler/make.top_level.m:
Add a note.
compiler/read_modules.m:
Conform to the changes above. Split the handling of source files
(which do not require search) from the handling of .int* and .*opt files
(which do).
compiler/analysis.file.m:
compiler/check_libgrades.m:
compiler/make.check_up_to_date.m:
compiler/make.get_module_dep_info.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile_front_end.m:
compiler/mmc_analysis.m:
compiler/options_file.m:
compiler/write_deps_file.m:
Conform to the changes above.
compiler/make.make_info.m:
When recording the mapping from a filename to a maybe timestamp,
record the list of directories we searched for that filename
next to the result of that search.
compiler/make.timestamp.m:
Record this extra info when adding entries to the file_timestamp_map.
After successful lookups in the file_timestamp_map, use this extra info
to return a valid SearchDirs result, for use in error messages.
Conform to the changes above.
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes above.
compiler/file_names.m:
Change the predicates that return file names to return as their result
both the current, legacy filename, and the proposed filename.
For ext_cur extensions, the legacy and the proposed filenames
will always be identical. Add a predicate for these that returns
just this one filename.
compiler/comp_unit_interface.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/fact_table.m:
compiler/generate_dep_d_files.m:
compiler/generate_mmakefile_fragments.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.check_up_to_date.m:
compiler/make.clean.m:
compiler/make.dependencies.m:
compiler/make.file_names.m:
compiler/make.get_module_dep_info.m:
compiler/make.library_install.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
compiler/make.track_flags.m:
compiler/make.util.m:
compiler/make_module_file_names.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/read_modules.m:
compiler/recompilation.used_file.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the changes above. In most places, this means ignoring
the proposed filename for now, but marking such places with "XXX LEGACY",
to make them easier to find when we *do* start to make use of the proposed
file names (first alongside the legacy names, and then without them).
In some places, make variable names more descriptive.
library/set.m:
Add utility predicate for use by a diff to one of the modules above.
NEWS.md:
Announce the new library predicate.
compiler/file_names.m
Separate "gs" (grade-specific but not architecture-specific) extensions
from "gas" (both grade- and architecture-specific) extensions.
The intent is to eventually install them into different directories,
but that is for future diffs.
Change the functions that return directory paths into predicates.
A future change will update them to return *two* directory paths:
one for the LEGACY directory structure, and one for the PROPOSED
structure.
compiler/compile_target_code.m
compiler/generate_mmakefile_fragments.m
compiler/make.clean.m
compiler/make.file_names.m
compiler/make.library_install.m
compiler/make.module_target.m
compiler/make.program_target.m
compiler/mercury_compile_llds_back_end.m
compiler/mercury_compile_main.m
compiler/module_cmds.m
Conform to the changes above.
compiler/make.make_info.m:
Rename two types that are conceptually maps to include "map"
in their names.
Rename the getter and setter operations on the fields of the make_info
containing values of these types accordingly.
compiler/make.library_install.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
compiler/make.top_level.m:
compiler/make.util.m:
Conform to the changes above.
Put .err_date files in grade-specific subdirectory when
--use-grade-subdirs is in effect.
compiler/file_names.m:
Replace ext_cur_ngs_misc_err_date with a new constructor,
ext_cur_ngs_gs_misc_err_date, in the ext_cur_ngs_gs category.
compiler/make.file_names.m:
compiler/make.module_target.m:
Conform the the above change.
compiler/mercury_compile_main.m:
Convert the values of the MERCURY_COLOR_SCHEME and NO_COLOR environment
variables into references to some (new) options, and insert the resulting
EnvVarArgs into the lists of options given to getopt.m through the
initial invocation of the handle_given_options predicate. And since
other parts of the compiler later reinvoke handle_given_options
(usually with module-specific options obtained from entries in
Mercury.options files), pass the value of EnvVarArgs to the other
parts of the compiler that do this.
compiler/make.build.m:
compiler/make.get_module_dep_info.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
Include the EnvVarArgs in the option list given to handle_given_options
in between the module-specific options from Mercury.options files
and the options we got from the command line. This sets up the
what-can-override-what relationships that we aim for.
compiler/handle_options.m:
Stop looking up the values of MERCURY_COLOR_SCHEME and NO_COLOR,
since that is now done by mercury_compile_main.m. Simplify the
affected code accordingly.
compiler/make.make_info.m:
Store the EnvVarArgs computed by mercury_compile_main.m in the make_info
structure, to transmit it to the components of the make package that
need it.
compiler/options.m:
Add the new options needed by all of the above. These include options
that record where the option that set the color scheme came from
(so that we place the blame correctly if the color scheme specification
is malformed), and an option that tells the special_handler predicate
to *ignore* the setting of the color scheme from MERCURY_COLOR_SCHEME.
This last one is intended to be used in tests/invalid/Mercury.options
to solve the problem of "how can we get Mercury.options to override
MERCURY_COLOR_SCHEME when we actually want to give our users a system
in which MERCURY_COLOR_SCHEME always overrides Mercury.options?".
tests/invalid/bug150_bad_color.{m,err_exp:}
A new test case that tests the message we should get when the value
of MERCURY_COLOR_SCHEME is malformed.
tests/invalid/bug150_partial_color.{m,err_exp}:
A new test case that tests the message we should get when the value
of MERCURY_COLOR_SCHEME specifies colors for some roles but not others.
tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
Enable the new test cases, and execute them with the intended options.
compiler/compile_target_code.m:
Get two predicates in this module to return error_specs instead of
printing them to stderr, since their callers know on what stream
these messages *should* be printed.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile_main.m:
Conform to the changes in compile_target_code.m.
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.
Move the code used for invoking commands via the shell out of the module_cmds
module and into its own module. In doing so, this moves it from the parse_tree
package into the libs package.
compiler/module_cmds.m:
Shift the code for invoking commands via the shell from here ...
compiler/system_cmds.m:
... to here.
compiler/libs.m:
Include the system_cmds module.
compiler/compile_target_code.m:
compiler/fact_table.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the above change.
compiler/notes/compiler_design.m:
Document the new module.
compiler/make.make_info.m:
Split that function symbol to three, one each for C, Java and C#.
compiler/make.module_target.m:
Conform to the change above.
compiler/make.check_up_to_date.m:
compiler/make.module_target.m:
Move the must_or_should_we_rebuild_lhs predicate, and the types it needs,
from make.module_target.m to make.check_up_to_date.m. Its subcontractors
should_we_rebuild_lhs and should_we_rebuild_lhs_given_timestamps are
already there, and that is where it belongs.
compiler/make.dependencies.m:
Use a bespoke type to represent the result of the search for prerequisite
files, to help clarify new code in the change below.
compiler/make.module_target.m:
The make_dependency_file predicate used to have three lines to make
the rhs files of an action (which it called the dependency files),
and dozens of lines to help decide whether to execute the action.
Move those three lines to its parent, and rename the predicate
to reflect the one job of the remaining code.
Simplify the code around the old call to make_dependency_file
by not trying to decide whether we *should* execute the make action
when we have already determined that we *cannot* execute it, due to
the making of some rhs file having failed.
Document a recursive call.
Delete a recently-obsoleted XXX.
... and the compilation task type foreign_code_to_object code.
The only code in the compiler that created a reference to either
was code to *remove* files identified by the module_target_foreign_object
target. It seems that all other code that created references to either
function symbol (as opposed to handling them after they were created elsewhere)
was deleted as part of the removal of the IL backend from the compiler
in 2015.
compiler/make.make_info.m:
Delete the above two function symbols from their types.
compiler/make.module_target.m:
Delete the code that used to handle the deleted function symbols,
and delete the XXX whose investigation led me to discover the fact
that this code has been dead for a while.
compiler/make.check_up_to_date.m:
compiler/make.dependencies.m:
compiler/make.file_names.m:
compiler/make.hash.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
compiler/make.util.m:
compiler/prog_foreign.m:
Delete the code that used to handle the deleted function symbols.
compiler/make.program_target.m:
Simplify the code that tests for the presence of errors. Do this by
- deleting the DepsSucceeded argument of the build_linked_target and
build_linked_target_2 predicates, because their caller has tested
its value before the call and knows that it is "succeeded",
- refining the type of the next argument in both predicates
to also reflect the fact that the caller has already tested it
for the absence of failure,
- using variables that reflect the success or failure of individual
steps in the overall process, instead of variables that encode
the success/failure of some combination of steps, but whose names
did not make clear *which* combination of steps they were about.
Add XXXs describing situations in which the outcomes of the old logic,
which the simplified logic preserves, seem to be suboptimal.
Break up a too-large predicate.
Give a predicate a more descriptive names.
compiler/make.check_up_to_date.m:
Split the lhs_result type into two types, to allow the second of the
simplifications above.
Give some predicates more descriptive names.
compiler/make.module_target.m:
Conform to the change in make.check_up_to_date.m.
compiler/make.module_target.m:
As above. This allows us
- to test whether an lhs file has a date file or not just once,
whereas previously we did it twice, and
- to take the timestamp of
Add comments about some other aspects of the code.
compiler/make.timestamp.m:
Delete a predicate whose only caller was deleted by the changes above.
compiler/make.file_names.m:
Rename timestamp_extension to date_file_extension. The file extensions
that this predicate returns all have "date" in their names, and thus
DateFile is a more readily understandable variable name than TimestampFile.
compiler/make.util.m:
Conform to the change in make.file_names.m.
compiler/make.check_up_to_date.m:
Clarify the meaning of the code here by
- replacing generic structures such as maybes with
semantically meaningful task-specific types,
- using purpose-specific predicates,
- moving code closer to the point where its output is needed,
- breaking up a too-large predicate,
- giving predicates and variables more descriptive names, and
- adding comments.
Also, add XXXs about problems that the above clarifications reveal.
compiler/make.module_target.m:
Clarify the meaning of the code here by pretty much the same methods.
One of the new predicates replaces one in make.timestamp.m.
compiler/make.program_target.m:
Conform to the changes above.
compiler/make.timestamp.m:
Delete code moved to make.module_target.m.
Since commit 25f8a6cc99, we only write
private interface files (.int0) for modules that actually have child
modules. However, find_files_maybe_touched_by_process_module still
returned a list of "touched" .int0 files for all nested submodules of
the top module, including submodules that do not have child modules.
Each time mmc --make is run, it would check for those unwritten .int0 as
dependencies, conclude that they were not up-to-date, and try to
generate them again (as part of generating the .int0 file for the
top module).
compiler/make.module_target.m:
Make find_files_maybe_touched_by_process_module exclude .int0 files
for nested submodules without child modules.
We introduced a cache of timestamps by target file in commit 4d4ef3e3a,
but when a target is made, only the timestamp for the main TargetFile
was invalidated, not the timestamps of other files that may also have
been touched, such as files for any nested submodules.
Fixes Mantis bug #569.
compiler/make.module_target.m:
Delete the timestamps of all TouchedTargetFiles in
record_made_target_given_maybe_touched_files,
not only the main TargetFile.
compiler/make.file_names.m:
Add back a predicate deleted by commit 764eab72a, since the special
treatment given by that predicate to module_target_source turned out
to be required. (It would have been nice if the test suite contained
a test case that demonstrated this fact.) Add this predicate back
with a name and with comments that clearly explain why it is needed.
compiler/make.module_target.m:
compiler/make.timestamp.m:
Call the added-back predicate in two out of the three call sites
where it used to be called. The third call site should not need it;
between jun 27 and nov 13, it contained code to check that both
the deleted predicate and its replacement (which lacks the special
treatment of module_target_source) returned the same result.
compiler/make.dependencies.m:
Move some of the code that surrounds the only call in the compiler to
find_target_dependencies_of_modules from make.module_target.m to here,
because doing so clarifies the relationship between the list of modules
being passed to that predicate.
Expand an old (dating from 2002) comment in the moved code, noting
the problems of the code it tries to explain.
Delete another, no-longer-needed comment in the moved code.
compiler/make.module_target.m:
Delete the moved code.
compiler/make.make_info.m:
Move another comment here from make.module_target.m, since it applies
to a data structure defined here.
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.
compiler/make.file_names.m:
Give related predicates related names.
Add an exported predicate module_target_to_maybe_for_search_file_name
as a version of the existing get_file_name_for_target_file predicate
(now renamed to module_target_file_to_file_name_maybe_search_module_dep)
that keeps the ability to specify either for_search or not_for_search,
but deletes its special handling of module_target_source. It is intended
to be used both to implement the non-module_target_source paths in
module_target_file_to_file_name_maybe_search_module_dep, and to be used
by call sites in other modules that don't handle module_target_sources.
Change the interface of target_type_to_target_extension. Instead of
returning info to its caller that require that caller to call it again
to get the info they actually want (i.e. the final extension), return
the final extension the first time.
compiler/make.module_target.m:
Conform to the changes above.
Update a comment about the code that this diff simplifies.
Pass a filename to a predicate, instead of requiring that predicate
to compute it again.
compiler/make.check_up_to_date.m:
compiler/make.get_module_dep_info.m:
compiler/make.timestamp.m:
Conform to the changes above.
These are issues I encountered while working on my previous commit
involving grab_modules.m.
compiler/make.make_info.m:
Give a name to the type that implements the data structure
that we usually use variables named DepStatusMap to refer to.
Rename the make_info field holding this data structure
from mki_dependency_status, which could mean any of several things,
to mki_dep_file_status_map, which pretty clearly says it maps
dependency_files to status information. (mki_dependency__file_status_map
would have been too long.) Rename the getter/setter predicates
accordingly.
compiler/make.check_up_to_date.m:
Do a similar clarifying rename on a predicate.
Convert an if-then-else to a switch.
Add a long XXX describing a problem I found while investigating
with some temporarily-failing test cases. Those test cases now succeed
despite the presence of this bug.
compiler/make.get_module_dep_info.m:
Delete code to write out error_specs that later code is guaranteed
to also write out on all possible execution paths. This resulted
in double-printed error messages in some test cases, which succeeded
despite this, because this problem occurred during compilation tasks
(such as the creation of .int3 files) that the test cases do NOT involve.
Speed up a search/insert operation pair.
compiler/mercury_compile_main.m:
Fix a sort-of bug that that included some error_specs in a list of
error_specs twice. The code writing out the error_specs would have
deleted the duplicates, but still, it is better to avoid adding
the duplicates in the first place.
compiler/make.program_target.m:
Merge two pairs of adjacent switches.
compiler/make.module_target.m:
Conform to the changes above.
.. that failed because the "For more information, recompile with `-E'
message was missing.
This diff takes the number of failed test cases in these grades
from 228-ish to 171.
compiler/make.module_target.m:
Stop calling the predicate that outputs that message outside
of the part of mmc --make's machinery that can fork the compiler process,
and ...
compiler/mercury_compile_main.m:
... ensure that it is called *inside* the forked process, in such cases.
Do this by ensuring that
- each switch arm in do_process_compiler_arg gathers up the error_specs
generated by code executed along that switch arm, and
- after the switch, do_process_compiler_arg prints both these
error_specs, *and* the "For more information, recompile with `-E'
message if warranted.
Previously, the last of those points happened on some execution paths,
but not all.
compiler/Mercury.options:
Stop specifying --no-warn-implicit-stream-calls for make.module_target.m.
compiler/make.module_target.m:
Use explicit streams when invoking mmc recursively for a target.
Add a call to maybe_print_delayed_error_messages. It does not fix
the problem it looks like it *should* fix, but it is almost certainly
a required step for that fix.
compiler/mercury_compile_main.m:
Take the explicit streams that make.module_target.m now passes.
compiler/write_error_spec.m:
Make the mutables consulted by maybe_print_delayed_error_messages
thread local. This should help, but it does not solve the problem.
compiler/make.build.m:
... as opposed to what you get from io.output_stream.
Change argument order to reflect our usual style.
compiler/make.get_module_dep_info.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes above.
... and almost all calls to get_error_output_stream. Replace them
with ProgressStreams and ErrorStreams passed down from higher in the
call tree.
Use ProgressStreams, not ErrorStreams, to write out error messages about
any failures of filesystem operations. These are not appropriate to put
into a module's .err file, since they are not about an error in the
Mercury code of the module.
compiler/globals.m:
Delete the predicates that return progress streams, and the mutable
behind them.
compiler/passes_aux.m:
Delete the predicates that return progress streams. Delete the
versions of the progress-message-writing predicates that didn't get
the progress stream from their caller.
compiler/*.m:
Pass around ProgressStreams and/or ErrorStreams explicitly,
as mentioned at the top of log message.
In a few places, don't write out error_specs to ErrorStream,
returning it to be printed by our caller, or its caller etc instead.
In some of those places, this allowed the deletion an existing
ErrorStream argument.
Given that get_{progress,error}_output_stream took a ModuleName input,
deleting some of the calls to those predicates left ModuleName unused.
Delete such unused ModuleNames.
In a few places, change argument orders to conform to our usual
programming style.
Fix too-long lines.
compiler/make.dependencies.m:
... through all the relevant predicates in this module. This fixes
all the "XXX MAKE_STREAM"s in the module.
compiler/make.module_target.m:
Pass ProgressStream to make.dependencies.m.
... instead of building a bunch of .c files.
Our tradition of adding an "s" at the end of a suffix to mean "all of the
files with the original suffix" had a problem when we added C# as a target
language. Until then, just as "os" stood for ".o files" when it occurred
as either a mmake target, mmc --make target, or mmake variable name component.
"cs" likewise stood for ".c files", but was now also needed to mean ".cs file".
We coped by keeping "cs" meaning ".c files", and adding "csharp" as a target
name synonym to mean ".cs file".
This diff keeps that synonym, but it changes
- the name needed to refer to ".c files" from "cs" to "all_cs"
- the name needed to refer to ".o files" from "os" to "all_os"
- the name needed to refer to ".pic_o files" from "pic_os" to "all_pic_os"
- the name needed to refer to ".cs files" from "css" to "all_css"
- the name needed to refer to ".java files" from "javas" to "all_javas"
- the name needed to refer to ".opt files" from "opts" to "all_opts"
- the name needed to refer to ".trans_opt files"
from "trans_opts" to "all_trans_opts"
It would be nice if we could apply this same change to all other similar
target names and mmake variable name suffixes, such as "ints" and "int3s",
but some of those names are already in use to mean semantically different
things. All of the names above that used to have the form "<ext>s" and
now have the form "all_<ext>s" stood for all the files with extension
".<ext>" that are prerequisites for building a linked target, i.e.
an executable or a library. But the mmake variable name suffixes
".all_mihs", ".all_mhs" and ".all_int0s" each stand for something subtly
different: the names of files that *may or may not exist", but which,
if they do exist, should be deleted by a clean or realclean target.
To make this breaking change easier to handle by users, this diff does
not simply redefine the meaning of ".all_int0s". (It does change the meaning
of the "cs" target, but the fact this will happen at some time has been
announced ages ago.) Instead, it defines three new mmake var suffixes,
".mihs_to_clean", ".mhs_to_clean" and ".int0s_to_clean", which are
synonyms for ".all_mihs", ".all_mhs" and ".all_int0s" respectively,
and announces that ".all_mihs", ".all_mhs" and ".all_int0s" are being
deprecated, and will have the above change of semantics applied to them
in the future.
NEWS.md:
Announce the breaking change.
compiler/make.top_level.m:
Stop treating the target "cs" as meaning "build all the .c files
for this program".
The code of classify_target_2 has long been semidet, but only in a way
that was not apparent to the compiler. Change the code to allow the
compiler to see its semidet nature while keeping the algorithm the same,
except for the change in the paragraph above.
This includes keeping e.g. "ints" as meaning "build all the .int/.int2
files needed by this program".
compiler/write_deps_file.m:
Stop generating mmake variables with suffixes ".cs", ".os", ".pic_os",
".javas" and ".css". The mmake variables with suffixes ".all_cs",
".all_os", ".all_pic_os", ".all_javas" and ".all_css" already existed.
All had the same value as the mmake variable without the "all",
with one exception: ".cs". However, in this case, the old (and still
current) value of ".all_cs" is what the value of ".cs" *should* have been.
Simplify some code.
The following changes in compiler/*.m are only cosmetic, but they helped me
rule out possible sources of problems with incomplete versions of this diff.
compiler/file_names.m:
Add a version of a fact_table_file_name_return_dirs which does not
return directories, since most of its callers don't need that info.
compiler/make.program_target.m:
Clarify code by making variable names more descriptive,
compiler/make.file_names.m:
compiler/make.module_target.m:
Conform to the changes above,
browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
grade_lib/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
Rename os to all_os, cs to all_cs, css to all_css, javas to all_javas,
and opts to all_opts. (There were no occurrences of trans_opts to rename.)
Replace [s as sh command names in actions.
scripts/Mmake.vars.in:
Specify the names of mmake variables holding the names of sets of files
with a given extension directly, since for some of them, adding an "s"
at the end of the name of the extension does not generate the name
of the corresponding mmake variable anymore.
scripts/Mmake.rules:
Use the directly specified mmake variable names from Mmake.vars.in
in the rule for installing lbraries. Temporarily add some debugging
output to make suree that the updated nested mmake variable references
work as intended.
tools/bootcheck:
Specify the names of mmake targets for making all the files in a program
with a given extension directly, since adding an "s" at the end of the
name of the extension does not generate the name of the corresponding
mmake target anymore.
Print timestamps around the action of checking namespace cleanliness,
to allow the time taken by that action to be measured. (I kept track
of bootchecks as they happened while working on this diff, and found
this time to be nontrivial.)
compiler/make.get_module_dep_info.m:
compiler/make.module_dep_file.m:
As above. make.module_dep_file now deals only with reading and writing
.module_dep files, as its name suggests, while make.get_module_dep_info.m,
which is significantly larger, manages the process of getting
module_dep_infos, which it can do either by finding .module_dep files,
or by building them if necessary.
compiler/make.m:
Include the new module.
compiler/notes/compiler_design.html:
Document the new module.
compiler/make.check_up_to_date.m:
compiler/make.dependencies.m:
compiler/make.file_names.m:
compiler/make.find_local_modules.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
Conform to the changes above.
Each of the new modules, and the old one, have improved cohesion.
compiler/make.check_up_to_date.m:
compiler/make.deps_cache.m:
compiler/make.find_local_modules.m:
Carve these new modules out of make.dependencies.m.
make.check_up_to_date.m contains code to test whether the other files
that the current target file depends on are up to date or not.
make.deps_cache.m contains the caches that make.dependecies.m uses,
which are also components of the make_info structure.
make.find_local_modules.m contains code to find the set of modules
in the current directory that a module (such as a module that
defines main/2) depends on.
compiler/make.m:
Include the new modules in the make package.
compiler/notes/compiler_design.html:
Document the new modules.
compiler/make.make_info.m:
Move two types here from make.dependencies.m, since they define
the type of one the pieces information stored in the make_info,
and they are also used by other modules.
compiler/make.dependencies.m:
Delete the code moved to other modules.
compiler/make.build.m:
compiler/make.deps_set.m:
compiler/make.file_names.m:
compiler/make.hash.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/make.util.m:
Conform to the changes above.