... 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.library_install.m:
Change the two predicates that install libraries to take as input
the list of the local modules in the libraries to be installed,
instead of computing those lists themselves. This work was unnecessary,
because their only call sites had that info already.
compiler/make.program_target.m:
Pass that info.
Move the code for computing that info into a separate predicate,
in order to make its new caller more focused and therefore more readable.
Make the moved code use a switch instead of an if-then-else.
Use more consistent variable names.
Delete unneeded parameters from two type constructors.
Add some XXXs.
compiler/check_libgrades.m:
Expand a predicate comment.
compiler/make.make_info.m:
... and give the type a non-misleading name.
compiler/make.prereqs.m:
Conform to the change above.
compiler/make.program_target.m:
Fix too-long line.
compiler/make.program_target.m:
Give several predicates and variables more descriptive
(and less misleading) names.
Document the reason for a design decision.
Merge two passes (one finding modules whose .java files should be
recompiled, one creating the names of those .java files) into one pass.
Don't try to create the directory containing those .java files, since
their existence requires the directory to have been built before.
Inline a tiny predicate at its only call site.
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.
Before this diff,
- the .d filed generated by "mmc --generate-dependencies mer_std.m", and
- the .d files generated by compiling all the modules in the library
had *two*-way differences: the first set of .d files contained dependencies
that the second did not, and *vice versa*. The latter differences were bugs.
Now, as far as I can tell from the deluge of data,
"mmc --generate-dependencies" generates a superset of the dependencies
generated by code generating compiler invocations, which is a safe
overapproximation of the actual dependencies.
compiler/generate_mmakefile_fragments.m:
Flatten the d_file_deps structure by effectively inlining the std_deps
structure inside it, and putting the resulting fields into a meaningful
order. Document the resulting structure as well as I can.
Use notag types to record the intended semantics of some fields
into their values, with the intention of making them harder to misuse.
They were misused before this diff; in particular, a missing module
name in one of these fields would reliably lead to the failure
of the hard_coded/foreign_import_module test case in hlc grades,
though only with a sequential invocation of mmake. (The bug was
that after "mmc --generate-dependencies foreign_import_module.m",
foreign_import_module.d was missing the dependency of
foreign_import_module.o on foreign_import_module_helper_1.mh,
and therefore the compilation foreign_import_module.c got a gcc abort
complaining about this .mh file being missing. The reason for
the bug being intermittent was that the mmc invocation that created
foreign_import_module.c would add the missing dependency, so *later*
mmake invocations, though not existing ones, would know
to build that .mh file.)
Generate rules for object files depending on .mh files that
account for both foreign_import_module declarations, and for
foreign type definitions. Add an XXX about the absence of the
information we need to properly handle the latter in the presence
of intermodule optimization.
Generate just one rule for object files depending on .mh files,
instead of generating two (one for the dependencies that exist
without intermodule optimization, and for one those that exist only
with intermodule optimization.)
Flatten the intermod_deps structure as well. It used to have two
components that encoded the outcomes of two *almost* identical tests,
but a change to d_file_deps.m below makes them actually identical,
so they do not need to be recorded twice.
Inline the old (and misnamed) gather_foreign_import_deps predicate
at its only call site, for greater clarity.
Simplify the code constructing some actions.
Use more specifically descriptive predicate and variable names.
compiler/d_file_deps.m:
Stop requiring the caller of construct_d_file_deps_gendep to pass
an aug_compilation_unit; get it to pass instead two of its components,
the only ones that are meaningful and also the only ones we actually need:
the parse_tree of the module in question and its baggage.
Eliminate some unnecessary differences between compute_d_file_deps_gendep
and compute_d_file_deps_hlds by replacing some existing tests for just
--intermod-opt with tests for *either* --intermod-opt *or* --use-opt-files,
which is the test used elsewhere for the same purpose in the rest of this
module. The two tests are equivalent for now, because handle_options.m
force-sets --no-use-opt-files. And even when we undo that force-set,
the new test will actually be what we want.
Completely redo the code that computes the dependencies that
generate_mmakefile_fragments.m converts into the dependencies
of object files on .mh files.
Give some predicates more meaningful names.
compiler/mmakefiles.m:
Add a mechanism to allow the simplification of some codes
creating actions.
compiler/module_deps_graph.m:
Give a type a more descriptive name.
Document a predicate.
Add an XXX.
compiler/make.program_target.m:
compiler/write_deps_file.m:
Conform to the changes above.
compiler/intermod.m:
Fix comment rot.
compiler/parse_tree_out_item.m:
Generate more readable output for foreign_enum pragmas.
library/digraph.m:
Put the predicates/functions of this file into meaningful groups.
We have several operations that have two names, one old and short,
and one newer, longer and more descriptive. Implement the short named
versions in terms of the longer named versions, not vice versa.
Give some internal predicates more meaningful names.
There are no algorithmic changes in this module.
browser/Mmakefile:
Update a comment.
scripts/mmake.in:
Allow $MMAKE_DEBUG to specify what debug flags to invoke gmake with.
compiler/options.m:
Consider all the options that used to be listed in the oc_buildsys section.
Keep many options as oc_buildsys, but reclassify others in option
categories that better fit their semantics. Create some new categories
for them.
To make that semantics more visible and understandable, give several
options more descriptive names,
Shorten some other names where this does not compromise understandability.
compiler/compile_target_code.m:
Rename do_make_init_obj_file to make_init_obj_file, after
- inlining the old make_init_obj_file predicate in its only caller, and
- deleting it to free up the name.
compiler/compute_grade.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/link_target_code.m:
compiler/make.build.m:
compiler/make.check_up_to_date.m:
compiler/make.dependencies.m:
compiler/make.library_install.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/mercury_compile_main.m:
compiler/op_mode.m:
Conform to the changes above.
compiler/color_schemes.m:
compiler/copy_util.m:
compiler/stack_alloc.m:
compiler/term_constr_initial.m:
Fix comments.
... to be used *only* when creating the globals.
compiler/options.m:
Add "only_globals" to the names of the three options.
compiler/globals.m:
Create *strongly* typed fields for the checked values of those options
in the globals.
compiler/handle_options.m:
Check the option values that options.m hasn't already checked,
and put the results into the initial globals.
compiler/link_target_code.m:
compiler/make.library_install.m:
compiler/make.program_target.m:
Get the checked values from the globals.
compiler/options.m:
Split the oc_link category into
- oc_link_c, oc_link_java and oc_link_csharp, for options that apply
to only one target language, and
- oc_link_c_cs and oc_link_c_cs_j for options that applyt to two or three
target languages.
Delete the long-obsolete mkinit_erl_command option.
The compile_to_shared_lib option had a misleading name, since it
did not contol compilation. Rename it to shared_lib_not_executable,
since that documents its purpose. (The external name stays, at least
for now.)
compiler/compile_target_code.m:
Give a predicate and some variables more descriptive names.
compiler/handle_options.m:
Document a possible bug.
compiler/link_target_code.m:
Factor out a piece of duplicated code.
In one place, reduce the extent of stringly typed programming.
compiler/make.program_target.m:
Replace an if-then-else with a switch.
compiler/mercury_compile_augment.m:
compiler/mercury_compile_llds_back_end.m:
Conform to the changes above.
compiler/mlds_to_java_file.m:
Improve a comment.
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.
This covers searches
- for static object file archives (usually .a files, since this is the default
value of the --library-extension option) when targeting C (we do this
for any Mercury library we want to link with), and
- for .init, .jar and .dll files (we do this *only* for the Mercury standard
library's top module).
The existing LEGACY search code treated .a, .jar and .dll files together,
and .init files separately from them. This diff keeps that treatment
for LEGACY searches, but changes things for PROPOSED searches, by searching
for .init, .jar and .dll files done *only* in the directory containing
the Mercury standard library.
compiler/globals.m:
Extend the ext_dirs_maps type with maps that specify the search paths
for the above four extensions.
Delete the dirs_ext type. Since recent events established the need
for different search paths for Mercury files in different circumstances,
the original point of this supertype (having a *single* map from
extensions to search paths) has been lost.
compiler/options.m:
Add options (which are not yet used) to control PROPOSED searches
for .a files.
Add an internal option for recording the location of the Mercury standard
library chosen by the user. The compiler sets this from the value of
another option, but if that option is not set, it falls back to the
directory named in an environment variable or a make variable
in an options file. The value of this option controls searches
for .init, .jar and .dll files.
compiler/handle_options.m:
Move the computation of the chosen standard library location here from
check_libgrades.m. Fix the potentionally-misleading wording of the
moved error messages.
Fill in the new fields of the ext_dirs_maps structure.
compiler/find_module.m:
Update the type representing search authorizations along the lines
described at the top of this commit message.
Implement the described PROPOSED searches for the four extensions,
while keeping their LEGACY searches the same.
compiler/file_names.m:
Update the type representing search specifications along the lines
described at the top of this commit message.
Provide auxiliary operations now needed by find_module.m.
compiler/check_libgrades.m:
Delete the code moved to handle_options.m. Simplify the rest of the module
as far as possible, given that the chosen stdlib dir is now available
in the option table, and we no longer need the env_optfile_variables
as inputs.
Ask to do PROPOSED searches for the Mercury std lib's main module
only in the chosen stdlib directory.
compiler/compile_target_code.m:
compiler/make.build.m:
compiler/make.library_install.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/mercury_compile_main.m:
Conform to the changes above.
compiler/options_file.m:
Fix indentation.
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.
... when checking whether the standard Mercury library is installed in
the current grade.
compiler/check_libgrades.m:
Change the interface of the maybe_check_libraries_are_installed predicate,
which does this check, to take an additional argument that contains
the value of MERCURY_STDLIB_DIR. Pass that value to (an updated form of)
the find_mercury_stdlib predicate, which the other main exported predicate
of this module has long used.
Generalize find_mercury_stdlib's interface to make the above possible.
And since it is now common betweeen the those exported predicates,
move it to the end of the module.
Change the data representation used by the find-the-grades-in-stdlib cache.
Instead of a single structure containing both the inputs of the test
and its output, use a separate one for the inputs. This simplifies both
parameter passing and the "does this set of inputs match the cache" test.
And, most important, it makes it easier to check whether we are using
any inputs that are not *listed* as inputs.
Include the value of MERCURY_STDLIB_DIR among those inputs.
Add an XXX about other things that should be listed as inputs.
Add some documentation. Delete the documentation of problems that
this diff fixes.
compiler/make.program_target.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.
The aim is to move all to this one place almost all the code that will
have to be updated to handle searches in the PROPOSED installed library
structure, first alongside and later in place of, searches in the LEGACY
structure. (Some code in handle_options.m, options.m and check_libgrades.m
will need to be updated as well.)
compiler/find_module.m:
Change the predicates of this module to take as input not a list of
directories to be searched, but a *specification* of how that list
should be computed. (Eventually, it should be possible to derive
this specification from the extension of the file name in most or
possibly even all cases, but that is future work.)
compiler/options.m:
Fix a misleading internal option name. (The user-facing name is
not misleading.)
compiler/maybe_error.m:
Add another purpose-specific synonym for bool, for use in changes below.
compiler/check_libgrades.m:
compiler/compile_target_code.m:
compiler/generate_dep_d_files.m:
compiler/handle_options.m:
compiler/make.check_up_to_date.m:
compiler/make.get_module_dep_info.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_main.m:
compiler/mmc_analysis.m:
compiler/options_file.m:
compiler/read_modules.m:
compiler/source_file_map.m:
compiler/write_deps_file.m:
Instead of computing lists of directories to pass to the predicates
of find_module.m, pass a specification.
Add "XXX SEARCH_ERROR" markers to code that should include more info
in error messages about failed searches.
The new code added by this diff is not yet used, though it can be
(and has been) tested manually.
compiler/generate_mmakefile_fragments.m:
Java and C# grades cannot (currently) can't be built by mmake.
So change the mmake actions we generate to install the grade-specific files
of Java and C# grades by invoking mmc --make, using the new target added
below.
Extend the cleanup we used to do after installs of C grades to do that
cleanup after Java and C# installs as well. Extend the set of files
we clean up accordingly.
compiler/make.library_install.m:
Add a new exported predicate to implement the new "mmc --make" target,
"lib%.install_gs_gas", where % is the name of the library.
Document of the existing exported predicate, to make clear what the
differences are between it and the new exported predicate.
Fix two copies of an error in existing but noy-yet-used code:
when installing .jar and .dll files, make the target directory
before copying the .jar or .dll file there. Without this, "cp"
mistakes the target's final pathname component as the intended name
of the copied file, not as final part of the target directory.
Clarify some existing code.
compiler/globals.m:
compiler/make.make_info.m:
Add the new "mmc --make" target to the list of such targets.
compiler/handle_options.m:
Add the user-visible name of the new "mmc --make" target
to the map from user-visible names to mmc-internal names.
compiler/make.program_target.m:
Invoke the new exported predicate in make.library_install.m if the
above map indicates that the current task is the new target.
compiler/make.top_level.m:
Translate the globals.m version of the new target to its make.make_info
form.
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.
compiler/make.library_install.m:
New module containing the parts of make.program_target.m that
deal with installing libraries.
compiler/make.clean.m:
New module containing the parts of make.program_target.m that
deal with cleaning up files. This new module provides functionality
both to make.library_install.m and the remaining parts of
make.program_target.m.
compiler/make.program_target.m:
Delete the code moved to the new modules. (Though this module
is still by far the largest in the make package.)
compiler/make.m:
Include the two new modules in this package.
compiler/notes/compiler_design.html:
Document the two new modules.
compiler/make.build.m:
Conform to the changes above.
compiler/file_util.m:
Move a piece of duplicated code to a predicate of its own, instead of
just documenting the duplication.
compiler/make.program_target.m:
Replace one copy of that repeated with a call to the new predicate.
Improve some variable and predicate names.
Mark where .module_dep files should probably be installed.
compiler/compute_grade.m:
Simplify the code constructing the string representation of a grade.
compiler/file_names.m:
Make a comment more readable.
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.
Put .mh files into a Mercury/mhs subdirectory when --use-subdirs
or --use-grade-subdirs is used.
compiler/file_names.m:
Replace ext_cur_mh with ext_cur_ngs_max_cur_mh, in the new category
ext_cur_ngs_max_cur. The new category is similar to that for .mih
files, except that .mh files are never placed in grade-specific
subdirectories.
compiler/handle_options.m:
Add Mercury/mhs subdirs to list of C include directories
when --use-subdirs or --use-grade-subdirs is in effect.
compiler/write_deps_file.m:
Add $(mhs_subdir) prefix before %.mh patterns.
Create a Mercury/mhs -> .. symlink when installing.
This is required by mmc --make and mmake --use-subdirs.
Conform to the changes above.
compiler/export.m:
compiler/make.file_names.m:
compiler/make.program_target.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mlds_to_c_file.m:
Conform to the changes above.
scripts/Mmake.vars.in:
Define the variable mhs_subdir.
scripts/Mmake.rules:
Add -I option to find .mh files when --use-subdirs is used.
browser/.mgnuc_copts:
browser/MDB_FLAGS.in:
compiler/.mgnuc_copts:
compiler/COMP_FLAGS.in:
deep_profiler/.mgnuc_copts:
deep_profiler/DEEP_FLAGS.in:
extras/EXTRAS_FLAGS.in:
grade_lib/.mgnuc_copts:
grade_lib/GRADE_LIB_FLAGS.in:
library/.mgnuc_copts:
mdbcomp/.mgnuc_copts:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/.mgnuc_copts:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/.mgnuc_copts:
profiler/PROF_FLAGS.in:
slice/.mgnuc_copts:
slice/SLICE_FLAGS.in:
ssdb/.mgnuc_copts:
ssdb/SSDB_FLAGS.in:
tests/.mgnuc_copts.ws:
tests/WS_FLAGS.ws:
trace/.mgnuc_copts:
tools/lmc.in:
Add -I options to find .mh files when the workspace is built
with mmake --use-subdirs.
samples/c_interface/standalone_c/Makefile:
Add option to let the C compiler find the .mh file.
NEWS.md:
Announce change.
Delete trailing whitespace.
compiler/analysis.framework.m:
compiler/analysis.operations.m:
Split the old contents of analysis.m between these two modules.
analysis.framework.m contains the general framework which may have
any number of instances; analysis.operations defines one instance.
compiler/analysis.m:
Replace this module's old contents with include_module declarations
for the two new modules above (as well as the existing include_module
for analysis.file).
compiler/analysis.file.m:
compiler/exception_analysis.m:
compiler/format_call.m:
compiler/handle_options.m:
compiler/hlds_module.m:
compiler/hlds_pred.m:
compiler/make.check_up_to_date.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/mmc_analysis.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.indirect.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/tabling_analysis.m:
compiler/trailing_analysis.m:
compiler/unused_args.m:
Conform to the changes above.
compiler/notes/compiler_design.html:
Add the new modules to the list currently undocumented modules.
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.
The compiler has long had code for recursively copying directories (via
"cp -R"), but it does not, in fact, use it anywhere.
compiler/make.program_target.m:
compiler/file_util.m:
compiler/module_cmds.m:
Delete unused predicates for copying directories.
compiler/globals.m:
compiler/handle_options.m:
Do not store the flag for copying directories in file_install_cmd
values.
compiler/options.m:
doc/user_guide.texi:
Delete the documentation for the --install-command-dir-option.
compiler/copy_util.m:
Delete the comment about moving directory copying to this module.
Delete the XXX about the Mercury copying code not preserving
permissions; it now attempts to do so.
NEWS.md:
Announce the deprecation of --install-command-dir-option.
Document why the compiler copies files and what mechanisms are available for
doing so.
When copying temporary interface files, do not use the Mercury copy_file
procedure as a fall back when invoking an external file copy command fails.
Use the value of the --install-method option to select whether we use an
external command to copy a file, or instead use a library procedure.
compiler/copy_util.m:
Document why the compiler (as opposed to mmake) copies files.
Document the mechanisms available to it for doing so.
Split copy_file/7 into two predicates: copy_file_to_file_name/7 and
copy_file_to_directory/7. These two predicate correspond to the
actual file copy use cases in the rest of the compiler.
Document some assumptions made by the rest of the compiler about
how file copying behaves.
Do not fallback to using the file copy procedure written in Mercury if
invoking an external command fails when copying a file to a file.
(When copying a file to a directory, we only ever used an external
command.)
Make the choice of file copy mechanism depend on the value of
the --install-method option.
compiler/make.program_target.m:
Use copy_file_to_directory/7 rather than invoking an external command
here directly.
compiler/module_cmds.m:
Use copy_file_to_file_name/7 here. Conform to changes in the way errors
are reported during file copying. There are couple of spots marked
XXX FILE COPY, where the caller previously assumed an io.error would
be returned to it -- this probably never happened in practice since
when using an external command invoke_system_command does the error
reporting. I'll tidy this up in a later change.
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.
When installing library grades with mmc --make, we change the grade and
enable the use of grade subdirs (if not already enabled) in the globals.
We must also clear the target file timestamp cache, as the information
it contains is only valid for a given grade and grade-subdir setting.
compiler/make.program_target.m:
As above.
compiler/make.timestamp.m:
Add an optional trace goal to check that a timestamp retrieved
from the cache matches the actual timestamp of the file on disk.
Rename get_target_timestamp_2 to get_target_timestamp_uncached.
... 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.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.
compiler/make.program_target.m:
Add a way to compute the sets of modules
- for which we want to generate .int, .int2 and .int3 files
- for which we want to generate .int0 files
in one pass, not three. Keep both computations for a while,
and check them against each other. In the meantime, move all parts
of the old three-pass algorithm next to each other.
Fix a misleading predicate name: make_all_interface_files could,
and if asked, did, build .opt files as well.
compiler/make.program_target.m:
All the multimodule tests in tests/invalid_make_int have been failing
in C# grades. The script for these tests has two main steps:
- build all the .int3 files involved, and then
- build the .int file.
The second step is expected to fail, with its error messages being tested,
but the first step is expected to succeed. The test cases were failing
because mmc --make built the .int files as part of the FIRST stage.
The cause was code that built all interface files (.int3, .int0,
.int/.int2 and even .opt) as a preliminary first step before actually
trying to act on *any* build-all target. The fix is to make this
preliminary step build only the interface files that come before
the build-all target's file kind in the build order. In this case,
that means not building anything in the preliminatu step of the
build-all-int3s target before building all the .int3s, thus leaving
the construction of the .int file for the second step, which is
*expected* to fail.
tests/invalid/exported_unify_helper_1.m:
Rename exported_unify2.m to exported_unify_helper_1.m in accordance
with our usual scheme.
tests/invalid/exported_unify.{m.err_exp,err_exp2}:
Update both expected error files for the rename. Since the .err_exp2 file
was ancient, this update fixed the test case failure for C# (and almost
certainly for Java) bootchecks. Note the role of each expected output
file in the source code.
tests/invalid/foreign_procs_exist_type.err_exp2:
tests/invalid/foreign_procs_exist_type.err_exp3:
Add these files containing the expected outputs for Java and C#.
tests/invalid/foreign_procs_exist_type.m:
Add a note about the role of each expected output file.
tests/invalid/foreign_procs_exist_type.err_exp:
Update the line numbers for this file containing the C expected output.
tests/invalid/foreign_purity_mismatch.m:
tests/invalid/fp_dup_bug.m:
For each C foreign proc being tested, add C# and Java foreign_procs
as well.
Add a note about the role of each expected output file.
tests/invalid/foreign_purity_mismatch.err_exp2:
tests/invalid/foreign_purity_mismatch.err_exp3:
tests/invalid/fp_dup_bug.err_exp2:
tests/invalid/fp_dup_bug.err_exp3:
Add these files containing the expected outputs for Java and C#.
tests/invalid/foreign_purity_mismatch.err_exp:
tests/invalid/fp_dup_bug.err_exp:
Update the line numbers for this file containing the C expected output.
tests/invalid/gh72_errors.m:
This test case tests an error message from the direct arg transformation.
This transform does not apply to C# and Java grades, so in those grades,
the compiler does not generate those messages. In those grades, this
test case failed because the compilation succeeds, instead of failing
(with the expected message, or not).
Fix this failure by adding to gh72_errors.m C# and Java foreign_procs
that do get error messages.
tests/invalid/gh72_errors.err_exp2:
tests/invalid/gh72_errors.err_exp3:
Expect these error messages in C# and Java grades respectively.
tests/invalid/gh72_errors.err_exp:
Update the line numbers in the error messages during C compilations.
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.