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.
compiler/read_modules.m:
When invoked to read a file specified by file name (as opposed to
by module name), the code of this module wrote out progress messages
to the current output stream, as returned by io.output_stream.
Fix this by consistently requiring the ancestors of the predicates involved
to pass an explicit stream to write progress messages to.
The interfaces of some of the exported predicates allowed their callers
to either pass a progress stream or not; if they didn't, this prevented
the generation of any progress messages with -v and the generation of
any statistics with -S. Most callers did specify the progress stream;
the main parts of the compiler that did not were
- the code that read the old versions of interface files in order to see
whether the new version was identical to it, or not, and
- the intermodule analysis framework.
This diff requires callers to always pass a progress stream, because
we *always* want to write out any error messages about nonexistent
or unreadable files, and we don't want to write these to an implicitly
specified file. We *could* add a parameter to the affected predicates
to shut up progress messages and statistics for use at the call sites
that previously passed us "no" as the maybe progress stream argument,
but I see no reason why one wouldn't want -v and -S to work as usual
in these above circumstances. If anyone ever finds such a reason,
there is a simpler fix anyway: turning off -v and -S in the globals
passed along next to the progress stream.
compiler/module_cmds.m:
Stop requiring an error stream and as well as a progress stream
when touching files. If the two streams were ever different, the
output would have looked strange, as the error message would NOT follow
the progress message announcing the operation that failed.
compiler/analysis.m:
compiler/deps_map.m:
compiler/generate_dep_d_files.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/recompilation.check.m:
compiler/write_module_interface_files.m:
Conform to the changes above, mostly by passing along
an explicit progress stream.
compiler/make.build.m:
If the compiler has not yet written to a module's .err file, then direct
the output from processing that module directly there. Use the old
algorithm, which is to direct that output to a temp file, and then
appending that the contents of the temp file to the .err file later,
only if this compiler invocation *has* written to the .err file before.
This should save the cost of a file copy in such cases.
Change the interface of the predicates that open and close the module error
stream to make the above possible.
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the change in the interface.
compiler/make.build.m:
The redirect/unredirect predicates originally did do what their
names said, but that hasn't been true for a while. This diff gives
them names that describe their current functionality, and changes
them to use a bespoke type for their return value.
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes in make.build.m.
In one place, add an XXX; in another, move an XXX.
compiler/make.build.m:
Replace one of the two remaining calls to io.output_stream
with an explicit stream passed from higher up in the call tree.
compiler/make.dependencies.m:
Replace many remaining calls to io.output_stream with an explicit stream
passed from higher up in the call tree, though some of these still get it
by calling io.output_stream themselves. Fixing these will require changes
to the same higher order predicate.
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/mercury_compile_main.m:
Pass the explicit stream that predicates exported from make.build.m
and make.dependencies.m now require.
compiler/make.file_names.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
Instead of getting streams by calling io.output_stream, get it from
higher up in the call tree. (There is still one place left in
make.program_target.m that does this, which may require further changes
elsewhere before it can be eliminated.)
compiler/make.build.m:
Add a version of an existing predicate that has its arguments reordered
to suit the requirements of another higher-order predicate.
compiler/make.module_dep_file.m:
compiler/make.timestamp.m:
Conform to the changes above.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
Replace code that writes progress messages to the implicit current
output stream with code that writes to an explicitly specified
progress stream. Pass that stream explicitly down to the code
that needs it.
compiler/make.build.m:
Add an explicit stream (the progress stream) argument to the predicates
that fold over mmc --make actions, since the actions (mostly in
make.module_target.m and make.program_target.m) now have such arguments.
compiler/mercury_compile_main.m:
Pass a progress stream to the top of the code of mmc --make.
compiler/Mercury.options:
Stop specifying --no-warn-implicit-stream-calls for make.program_target.m
and make.top_level.m. (make.module_target.m contains some still-needed
stream redirection code that would get such a warning.)
compiler/make.build.m:
Require callers to specify an output stream to replace
a previously-implicit stream.
compiler/Mercury.options:
Stop specifying --no-warn-implicit-streams for make.build.m.
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Pass the stream now required by make.build.
compiler/make.module_dep_file.m:
Rename the main exported predicate, get_dependencies, to
get_maybe_module_dep_info, since while the latter expresses its purpose
much more precisely. Rename some of its subcontractor predicates
in a similar fashion.
Clarify the structure of a predicate by replacing a seeming three-way
switch with code that reflects its actual structure: one two-way switch
nested inside one arm of another two-way switch. Move code needed
only on some paths to be executed on just that path.
Update an example.
compiler/make.dependencies.m:
compiler/make.file_names.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
Conform to the changes above.
compiler/make.module_dep_file.m:
Replace all I/O done to implicit streams with I/O to explicit streams.
We cannot yet disable --no-warn-implicit-stream-calls for the module,
because it still contains code to change the current output stream.
compiler/make.dependencies.m:
compiler/make.file_names.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.timestamp.m:
compiler/mercury_compile_make_hlds.m:
Conform to the change in make.module_dep_file.m.
compiler/make.dependencies.m:
Replace all I/O done to implicit streams with I/O to explicit streams.
compiler/Mercury.options:
Stop specifying -no-warn-implicit-stream-calls for make.dependencies.m.
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes in make.dependencies.m.
In make.module_target.m, reclassify some existing use of explicit streams
from debug to progress messages, because the messsages make sense only
when synchronized with actual progress messages.
compiler/make.util.m:
Delete the versions of maybe_write_msg and maybe_write_msg_locked
that wrote to the (implicit) current output stream. The versions
that write to an explicitly specified stream remain.
Change the old callers to the deleted predicates to pass an explicit
stream to the remaining versions. To make this possible, require *their*
callers to specify an explicit stream.
Give two predicates less-confusing names.
compiler/Mercury.options:
Stop specifying -no-warn-implicit-stream-calls for make.util.m.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes in make.util.m. In most places, we do still use
implicit streams, but moving such uses higher and higher in the call tree
gets us closer and closer to using only explicit streams.
compiler/file_names.m:
Replace the current groups of extensions, which are based on the
shared purpose of the files with those extensions, with a smaller
number of groups, which are based on the algorithm we use to decide
in what (sub)directories we want to place files with those extensions.
The old distinctions based on purpose still remain in the naming
convention for the enum values within each of the new groups.
compiler/analysis.file.m:
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/generate_dep_d_files.m:
compiler/llds_out_file.m:
compiler/make.file_names.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.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/mlds_to_c_file.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/prog_foreign.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.
Each of the new modules, and the new make.util.m, has better cohesion
than the old make.util.m. (For example, the lists of modules they import
don't overlap all that much.)
compiler/make.file_names.m:
compiler/make.hash.m:
compiler/make.timestamp.m:
Carve these three modules out of make.util.m
- make.file_names.m does filename translations.
- make.hash.m does hashing.
- make.hash.m looks up and compares timestamps.
compiler/make.m:
Include the new modules.
compiler/notes/compiler_design.html:
Document the new modules.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/make.util.m:
Update module imports.
We have been using the maybe_search type to represent two related
but slightly different concepts:
- whether we are computing a filename *to search for*, and
- whether we are computing a filename *by searching*.
This diff changes things so that we use two different types to represent
these concepts: maybe_for_search for the first, and maybe_search for
the second. Expressing this distinction in the type makes the affected code
easier to understand.
compiler/file_names.m:
Define maybe_for_search, document it, and update the documentation
of maybe_search.
Use maybe_for_search throughout this module, since it never does
any searching,
Update some other comments.
Add a function to convert from maybe_search to maybe_for_search.
This is needed because to search for something, you first need
to know what to search for.
compiler/make.module_target.m:
compiler/make.util.m:
Change all the occurrences of the old maybe_search type that actually
control whether we are computing a filename *to search for* into
maybe_for_search.
compiler/module_cmds.m:
Rename the update_interface_X predicates to copy_dot_tmp_to_base_file_X,
because
- this better describes what they do, and
- some of the files they are invoked on are *not* interface files.
Add an extra parameter to copy_dot_tmp_to_base_file_report_any_error
that specifies what kind of file is being copied, and print *that*
as part of any error message.
Do a similar rename of update_interface_result type, and of its
function symbols.
Give more meaningful names to touch_interface_datestamp and
touch_datestamp as well.
compiler/analysis.file.m:
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/export.m:
compiler/intermod.m:
compiler/make.module_target.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/mlds_to_c_file.m:
compiler/recompilation.check.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/handle_options.m:
The main predicate of this module, handle_given_options, used
to generate the default option table every time it was called,
and its callers couldn't prevent this by supplying it with that
default option table. Fix this by adding an argument for that info.
compiler/mercury_compile_main.m:
Create the default option table at the start of real_main_after_expansion.
Pass it to later invocations of handle_given_options.
compiler/globals.m:
Include the default option table, as well as the processed option table
(created by handle_given_options from the default table) in the globals
structure. This is so that the parts of the make package that want to
build a new globals structure "from scratch" don't have to redo
the part of the work that is independent of the set of actually specified
options.
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
Conform to the changes above.
In some cases, fix misleading variable names.
In make.track_flags.m, add an XXX outlining a possibly better approach
to hashing options for tracking.
library/Mmakefile:
Stop copying a part of getopt_io.m to geteopt.m, because it is
confusing as hell after an automatic edit.
library/getopt.m:
Expect the effect of the change to library/Mmakefile.
compiler/file_names.m:
Take ext_src out of the ext type, because this allows us to delete
the I/O state pair of arguments out of every file translation predicate
other than module_name_to_source_file_name and the ones that create
directories.
compiler/file_kind.m:
Delete the ext output argument of file_kind_to_extension, because
we can't return ext_src for fk_src anymore.
compiler/write_deps_file.m:
Delete a test for ext_src which could never succeed, because the
predicate in question is never called with ext_src.
Undo an accidental change from the diff that introduced
module_name_to_lib_file_name_create_dirs.
Conform to the changes above.
compiler/compile_target_code.m:
compiler/fact_table.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.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/mlds_to_c_file.m:
compiler/mmc_analysis.m:
compiler/module_cmds.m:
compiler/read_modules.m:
compiler/recompilation.used_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/file_names.m:
Split module_name_to_file_name into three versions.
- One corresponds to the old predicate's operation with do_not_create_dirs,
- one corresponds to the old predicate's operation with do_create_dirs, and
- one just returns the directory path, and lets the caller make those
directories if it wants to, using procedures that we now export.
Do the same for module_name_to_lib_file_name.
Do not do the same for fact_table_file_name, which has too few callers
to make it worthwhile.
The point is that the versions that do not create any dirs should NOT
need to take I/O state pairs as arguments, once we take ext_src
out of the ext type.
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/fact_table.m:
compiler/generate_dep_d_files.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/make.util.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:
Update calls to the affected predicates.
In some places, add XXXs about seemingly-strange choices about
what calls create directories and which don't.
compiler/file_names.m:
Delete the old code for doing filename translations, and use
just the new code.
Delete all the code that was needed only for comparing the old and
new code.
Delete the newext_other extension category, since it was also needed
only for that purpose. Delete all the code that supported it.
Switch the infrastructure for recording the demand for translations
to work with the new code.
compiler/analysis.file.m:
Delete functions that returned old-style extensions, which are
not useful anymore. The new-style extensions, by identifying
extensions via enums rather than strings, serve the purpose
for which these functions were created.
compiler/mercury_compile_main.m:
Move the code to call to write out the translation record
from just after a call to real_main_after_expansion to the
end of real_main_after_expansion. The reason is that the
predicate being called now needs access to a globals structure,
real_main_after_expansion has access to a globals structure,
but its caller does not.
Don't try to test the equivalence of the old and new algorithms
for file name translation, since that test code has been deleted.
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.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/prog_foreign.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 in file_names.m.
compiler/make.util.m:
Add verbose_make_N_part_msg predicates, and the more general
option_set_make_N_part_msg predicates, to allow simpler code
to construct progress and informational messages.
Pass to debug_make_msg a message *generator*, instead of a predicate
that *writes out* a message. Make debug_make_msg return the message
(if debug_make is enabled) to be written out (hopefully) to an explicitly
specified stream.
compiler/make.dependencies.m:
Rename the dependency_status predicate to get_dependency_status.
Make it return the original dependency_file, and the filename it
corresponds to, alongside the status, because this is the simplest
way to avoid requiring its callers to reconstruct that information
after their calls to get_dependency_status.
Change the signature of check_dependency_timestamps to expect
the new output of get_dependency_status.
Replace code to write out debugging messages with code to just return
them as a string. Move one of these predicates to just after its caller.
Give some predicates more descriptive names.
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes above.
In make.program_target.m, add XXXs about progress messages
that end with a period, unlike all the other progress messages.
compiler/make.util.m:
The predicates that handled progress messages in this module
- tested whether the progress message was needed, and if yes,
- first constructed the message,
- and then printed it.
The predicates that handled error messages were similar,
but error messages are always needed.
In most cases, the printing was done to the current *implicit* output
stream.
Code calling these predicates won't get warnings about implicit stream
calls unless every predicate has both implicit and explicit stream
variants.
Make all these predicates do just the first two of the above jobs,
and return a string that may be empty or not. Then require callers
to call one of four new predicates to print out the resulting string
if it is not empty. The four are distinguished along two axes:
implicit vs explicit stream, and locked/unlocked stdout.
Add XXXs about the problems of even this updated approach,
including the one with locking stdout when the output stream,
whether implicitly or explicitly specified, is *not* stdout.
Make the names of all the predicates affected by the above change
end in "_msg". Change some of the names to be more descriptive.
Delete one predicate whose code was identical to that of another.
compiler/make.build.m:
Export the lock/unlock stdout predicates for use by the new predicates
in make.util.m.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
Conform to the changes above.
compiler/make.program_target.m:
Conform to the changes above.
Give a predicate a less misleading name.
Add an XXX in a place.
The main purpose of this change is not extra efficiency, but uncovering
inconsistencies, and in fact, it found one. A secondary purpose is preparing
for the use of explicit streams in the make package.
compiler/make.util.m:
Avoid such a conversion in the debug_file_msg predicate by requiring
the caller to supply not a target file, but the result of the conversion.
Create separate do_not_search and do_search versions of the
module_TARGET_to_file_name predicate, to reduce the unnecessary
differences between this predicate (now these predicates) and the
corresponding code in file_names.m, i.e. module_NAME_to_file_name/
module_NAME_to_search_file_name. The point of this is to make it easier
to compare two predicates that may, or may not, do identical jobs
using different code, as noted by the new XXX in make.module_target.m.
Put do_not_search code before do_search alternatives, again following
the pattern in file_names.m.
compiler/make.module_target.m:
Update the calls to debug_file_msg.
In one case, add an XXX for the fact that the filename corresponding
to a target file is computed twice, in two different predicates, using
two seemingly different algorithms.
compiler/make.util.m:
As above.
compiler/compile_target_code.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
Conform to the changes in make.util.m.
This should allow profiling runs to collect information about the
number of accesses to each field.
compiler/make.make_info.m:
Move the definition of the make_info type from the interface section
to the implementation section. Add getter functions for all its fields,
setter predicates for its writeable fields, and an initialization
function.
Move all the readonly fields to the start of the structure.
Put related fields next to each other.
compiler/make.top_level.m:
Replace the explicit construction of the initial make_info value
with a call to its initialization function.
compiler/make.build.m:
compiler/make.dependencies.m:
compiler/make.deps_set.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/make.util.m:
Replace all accesses to the fields of make_info with calls to the
getter functions or the setter predicates.
compiler/file_names.m:
Change the argument vectors of the predicates that compute filenames
by taking *two* arguments to specify the extension: adding an argument
value of the "newext" type right after the old "ext" type. To make this
possible, export the newext type.
By default, use the new argument to do every filename computation twice,
with the old and new algorithms, throwing an exception if their results
differ. (There is no easy way to test whether the "make-any-needed-dirs"
part was done the same way, but this is reasonably easy to check
visually in the code.)
In case an exception does get thrown, this can be suppressed (hopefully
after the exception being reported) by setting the environment variable
"NO_EXT_CHECKS" to any value.
Add representations of "get the value of this extension from this option"
style extensions to the newext type, for each of the options that the
compiler uses this way. The one exception is java_object_file_extension,
which was used in this way, but which had no code handling it in
file_names.m.
Add a representation of ".$(EXT_FOR_PIC_OBJECTS)" as a value
to the newext type.
Shorten some function symbol names in the newext type and its components,
to make them easier to fit without excessive line lengths in the modules
listed below.
compiler/analysis.file.m:
compiler/analysis.m:
compiler/compile_target_code.m:
compiler/du_type_layout.m:
compiler/export.m:
compiler/fact_table.m:
compiler/file_kind.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.track_flags.m:
compiler/make.util.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/prog_foreign.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:
Pass extensions as ext/newext pairs, not just as exts.
To make this possible, change functions and predicates that returned
just old-style extensions to return new-style extensions as well.
compiler/make.program_target.m:
Pass extensions as ext/newext pairs, not just as exts.
Add an XXX about java_object_file_extension for Julien, since he added
this option (in 2001 :-().
compiler/make.util.m:
Many operations in this module that operate on filenames did not take
those filenames as arguments; instead, they took an argument such as
a target_file from which they *computed* the filename. This meant that
any predicate that called more than one of these operations implicitly
computed the filename more than once. This could be a problem, because
- there are several predicates one can use to compute the filename, but
- there is no guarantee that different operations use the same predicate.
As a first step in fixing this, change the predicates that print
filenames in progress or error messages to take those filenames
as parameters. Delete one of them, target_file_error, because
after this change, it would have become identical to the existing
file_error predicate.
compiler/make.module_target.m:
Require the callers of record_made_target to supply the filename
as well as the target_file from which it is derived.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
Compute the filename before calling the updated operations in make.util.m
and/or make.module_target.m.
Add "XXX MAKE_STREAM" to places in the code that operate on either
implicit or badly-chosed explicit streams.
compiler/make.module_target.m:
Inline the (badly named) make_module_target_file_extra_options predicate
at its only call site in make_module_target. Factor out the commonalities
between the dep_file and dep_target parts of make_module_target, which
(after the above inlining) jump out at you.
make_module_target_main_path used to handle the main path *and* one
special case. Move the code to test for, and handle, that special case
to make_module_target. Since the code handling the special case
involves calling make_module_target with modified arguments, this move
also replaces mutual recursion (which originally involved three predicates)
with self-recursion.
compiler/file_names.m:
Document the meaning of the maybe_create_dirs and maybe_search types.
Delete long-obsolete references to .il files.
compiler/make.util.m:
Rename make_remove_target_file to remove_make_target_file, since this
predicate removes target files in Makefiles, and does not "make" anything.
Rename several other predicates in a similar manner, for the same reason.
Add an extra argument to get_file_name and some related predicates
that will allow future conditionally-enabled trace goals in the compiler
to track where the requests for file name translations come from.
compiler/write_deps_file.m:
Factor out some code.
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Conform to the changes above.
tools/file_name_translation_stats:
Allow for large numbers of file name translations.
compiler/prog_foreign.m:
foreign_language_module_name and foreign_language_file_extension
were both functions with two modes, one of which was semidet.
Since semidet functions violate the law of least astonishment,
turn both into predicates.
Change the semidet mode into det (this has been possible ever since
we deleted the Erlang backend). Then comment out the other mode,
since it has no use left.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
Update the calls to the affected functions (now predicates).
compiler/make.util.m:
... after inlining some of their at their only call sites.
The rest were unused.
The inlining should (eventually) help the call sites to avoid
redundant conversions from make's representation of target files
to their actual filesystem names. Eventually, because at the moment,
the other conversions are hidden somewhere in their call trees.
Keep one make_write_X predicate after renaming it to write_make_X.
Add XXXs about possible bugs.
compiler/make.dependencies.m:
Replace a higher order arg that wrote out a filename with one
that just returns that filename.
Improve some debugging output slightly.
compiler/make.module_target.m:
Inline the former make_write_X predicates.
Add XXXs about possible bugs.
compiler/make.program_target.m:
Conform to the change in make.dependencies.m.
compiler/maybe_util.m:
Move the maybe_changed type from several modules of the compiler
to maybe_succeeded.m, and rename it to maybe_util.m.
compiler/libs.m:
compiler/notes/compiler_design.html:
Implement and document the rename.
compiler/common.m:
compiler/compile_target_code.m:
compiler/decide_type_repn.m:
compiler/det_analysis.m:
compiler/det_util.m:
compiler/equiv_type.m:
compiler/equiv_type_hlds.m:
compiler/file_util.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_c_type.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/module_cmds.m:
compiler/parse_tree_out.m:
compiler/process_util.m:
compiler/recompilation.version.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
compiler/make.dependencies.m:
Create find_target_dependencies_of_modules, a version of the
deps_set_foldl3_maybe_stop_at_error_find_union_fi predicate
that is specialized to the call site make.module_target.m
that passes make.dependencies.m's target_depencies function
as its FindDeps argument.
Make some exported types/insts private, now that this is possible.
Eliminate an unnecessary recursive call. Put the different target types
into an approximately ascending order of complexity.
compiler/make.module_target.m:
Call the new specialized predicate.
Make some code more readable.
This change improves the run time of a do-nothing build of Prince using
mmc --make on my machine from 1.46 s to 1.19 s.
compiler/make.make_info.m:
Use version_hash_table for the target_file timestamps cache
instead of a tree234 map.
compiler/make.util.m:
Add function to initialised a target_file_timestamps.
Conform to change in type.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
Conform to change in type.
Add a comment about a possible change.
compiler/make.dependencies.m:
Specialize the remaining uses of deps_set_foldl3_maybe_stop_at_error_mi,
and then delete it. Also delete the type and inst that also it used.
Delete all the *foldl3* predicates whose only task was to call the
corresponding loop predicate, after inlining them at all their call sites.
Then transfer their names to their loop predicates.
Stop exporting the *foldl* predicates that are not used outside this
module.
Give a predicate a more expressive name.
compiler/make.module_target.m:
Conform to the changes above.
compiler/make.dependencies.m:
Most calls to deps_set_foldl3_maybe_stop_at_error_{mi,fi} call them
with closures that package up the union_deps predicate or its
union_deps_plain_set. Create new versions of these predicates that
in effect
- replace the higher order call to the closure argument with a first order
call to union_deps or union_deps_plain_set, and then
- inline the call.
This reduces the height of the higher-order upon higher-order stack by one.
It also deletes the last remaining calls to union_deps and to
union_deps_plain_set, so this diff deletes them.
The new versions completely replace all uses of
deps_set_foldl3_maybe_stop_at_error_mi, so delete that predicate.
Move two local types to the top of the implementation section.
Before this diff, they were defined *after* their first use.
Note the need for documentation.
compiler/make.module_target.m:
Eliminate a reference to union_deps here as well.
compiler/make.build.m:
Replace foldl2_maybe_stop_at_error_{df,str,tt} with
foldl2_make_module_targets, foldl2_install_library_grades and
foldl2_make_top_targets respectively. Each of the new predicates
now knows
- the operation being folded over the given list,
- the type of the elements in the list it folds over,
- the types of the two accumulators,
The first is also expressed in the new predicate name, while the
second and third of these are expressed in its type signature.
Another change in each signature is the replacement of the higher order
argument specifying the operation with the its optional arguments, if any.
The loop predicates that do the work in each case are unchanged,
at least for now.
Replace foldl2_maybe_stop_at_error_maybe_parallel_df with
foldl_make_module_targets_maybe_parallel, making the same changes as above.
Delete foldl2_maybe_stop_at_error_{mi,fi} and
foldl2_maybe_stop_at_error_maybe_parallel_mi, since they turned out
to be unused. (Their foldl3 versions do look to be needed.)
compiler/make.dependencies.m:
Conform to the changes above.
Give some predicates more expressive names.
compiler/make.module_target.m:
Replace two predicates make_module_target and
make_module_target_extra_options, with only the latter taking
a list of extra options, with just one predicate,
named make_module_target but taking a list of extra options.
This allows foldl2_make_module_targets to work the same whether or not
the list of extra options is empty.
Conform to the changes above.
compiler/make.program_target.m:
Conform to the changes above, including by exporting the predicate
install_library_grade predicate for foldl2_install_library_grades.
compiler/make.top_level.m:
Conform to the changes above, including by exporting the predicate
make_target predicate for foldl2_make_top_targets. Rename this
predicate to make_top_target to help differentiate it from
make_module_target.