Estimated hours taken: 3
Branches: main
Clean up the conversion of targets to file names by `mmc --make'.
Don't assume that every target can be converted simply by adding
an extension -- this isn't true for object files for foreign code
or fact tables.
compiler/make.m:
compiler/make.*.m:
s/factt_object/fact_table_object/
Instead of having one fact_table_object target for each module,
have one for each fact table file. Previously it wasn't possible
to identify a fact_table_object target with a target file without
additional information.
compiler/make.util.m:
compiler/make.*.m:
make_util.target_extension now returns a `maybe' type, since
foreign code and fact table targets can't be converted to
file names by adding an extension.
Add predicates module_target_to_file_name and
module_target_to_search_file_name which are like
module_name_to_file_name, but which handle the
special cases for foreign code and fact tables
correctly.
Estimated hours taken: 1
Branches: main
Fix a bug which caused `mmc --make foo.o' to fail.
compiler/make.m:
compiler/make.util.m:
Avoid returning multiple possible file types for object files.
compiler/compile_target_code.m:
For the (in, out, in) mode of maybe_pic_object_file_extension,
always return `non_pic' if the platform doesn't need special
handling for PIC.
tests/mmc_make/Mmakefile:
tests/mmc_make/build_object:
Test case.
Estimated hours taken: 2
Branches: main
compiler/*.m:
Import only one compiler module per line. Sort the blocks of imports.
This makes it easier to merge in changes.
In a couple of places, remove unnecessary imports.
Estimated hours taken: 20
Branches: main
Move the setting of configuration options from mmc.in to
an options file Mercury.config. This has a few advantages:
- reduces the duplication between mmc and mercury.bat
- reduces the chance of running out of environment space
on crappy operating systems (although we probably exceed
the command line length limits on those systems anyway).
- makes it easier to bootstrap changes which add new
configuration options.
Always read the options files, even without `--make',
to avoid inconsistent behaviour.
scripts/Mercury.config.in:
New file containing the configuration code from mmc.in.
configure.in:
Create scripts/Mercury.config.
bindist/Mmakefile:
Make sure Mercury.config.in goes in the binary distribution.
Mmakefile:
bindist/Mmakefile:
Mmake.common.in:
Make sure we get the correct setting of INSTALL_PREFIX
when building the binary distribution.
scripts/Mmakefile:
scripts/mercury_config.in:
bindist/bindist.Mmakefile.in:
Install Mercury.config.
compiler/options.m:
doc/user_guide.texi:
Add documentation for the `--config-file' option, which gives
the name of the configuration file to read.
Add an option `read-config-file-2003-03-01' which will be
used in configure.in to test whether the compiler is up
to date after the configuration code is removed from mmc.in
(after this change is installed everywhere).
Add `--mercury-config-dir' as an abbreviation for
`--mercury-configuration-directory'.
Mmake.workspace:
Use the configuration file in scripts/Mercury.config.
browser/Mmakefile:
compiler/Mmakefile:
scripts/Mmake.vars.in:
Always pass ALL_MCFLAGS to mmc so that mmc will
use the configuration file specified in the options.
compiler/handle_options.m:
Handle the default value of `--config-file'.
compiler/mercury_compile.m:
Read the configuration file.
Always read the options files, even without `--make',
to avoid inconsistent behaviour.
compiler/make.m:
Pass the variable settings from the configuration file
to make__process_args.
The options files have already been read in mercury_compile.m,
so don't read them again here.
compiler/make.util.m:
Add a version of build_with_module_options which doesn't
need a make_info, for use by mercury_compile.m.
compiler/options_file.m:
Export a predicate to read a single options file.
Make the predicates to read options files add to an initial
options_variables map, rather than always creating a new one.
Allow MERCURY_STDLIB_DIR and MERCURY_CONFIG_DIR
to be set in the options file or environment.
scripts/mmc.in:
Set MERCURY_STDLIB_DIR and MERCURY_CONFIG_DIR in
mercury_compile's environment.
Estimated hours taken: 70
Branches: main
Add Java support to the foreign language interface.
mercury/compiler/compile_target_code.m:
mercury/compiler/make.module_target.m:
mercury/compiler/mercury_compile.m:
Pass `compile_java_file' a Java filename rather than a module name.
mercury/compiler/globals.m:
Add `java' as a `foreign_language'.
mercury/compiler/handle_options.m:
Allow Java as a back-end foreign language if the target language
is Java.
mercury/compiler/hlds_data.m:
Allow Java foreign_types.
mercury/compiler/intermod.m:
mercury/compiler/foreign.m:
mercury/compiler/make.util.m:
mercury/compiler/make_hlds.m:
mercury/compiler/mercury_compile.m:
mercury/compiler/mercury_to_mercury.m:
mercury/compiler/ml_code_gen.m:
mercury/compiler/mlds.m:
mercury/compiler/mlds_to_c.m:
mercury/compiler/mlds_to_il.m:
mercury/compiler/mlds_to_ilasm.m:
mercury/compiler/mlds_to_java.m:
mercury/compiler/pragma_c_gen.m:
mercury/compiler/prog_data.m:
mercury/compiler/prog_io_pragma.m:
Add or modify existing code to support `java' as a `foreign_language'
and Java `foreign_type's.
mercury/compiler/mlds_to_java.m:
Nicely indent the generated code that unboxes arguments from
return-argument arrays which are used for methods with multiple
return arguments.
Estimated hours taken: 20
Branches: main
Make it easier to use shared libraries on x86 with
`mmc --make'.
There is now a third kind of object file, `.lpic_o'.
These files are compiled with `--pic-reg' but not with
CFLAGS_FOR_PIC, so they can be linked with shared Mercury
libraries.
On x86, executables which are linked with shared Mercury
libraries now depend on $(main_module.lpic_os), not
$(main_module.os).
This doesn't work with Mmake because ml doesn't know
which libraries are Mercury libraries, so it can't
link with the static versions of those libraries if
MERCURY_LINKAGE is set to "static".
configure.in:
bindist/bindist.configure.in:
bindist/bindist.build_vars.in:
Work out whether `.lpic_o' files are needed.
compiler/modules.m:
Add `.lpic_o' to the list of grade or architecture
dependent files.
NEWS:
README.Linux:
compiler/options.m:
doc/user_guide.texi:
Document MERCURY_LINKAGE, LINKAGE, --linkage,
--mercury-linkage and -R.
compiler/options_file.m:
compiler/make.program_target.m:
Handle LINKAGE and MERCURY_LINKAGE variables.
Allow LIBGRADES, LINKAGE and MERCURY_LINKAGE to be target-specific.
scripts/mmc.in:
Set up the default linkage using the MERCURY_LINKAGE
variable.
compiler/compile_target_code.m:
Build `.lpic_o' files.
Work out which type of object files to link with.
When linking statically with Mercury libraries,
find the absolute pathname for the `.a' file
for each Mercury library, and pass that to ml,
rather than just using `-lname'.
Pass `-R' options to ml for each `-R' option to mmc.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile.m:
Specify which type of object files to build.
compiler/make.program_target.m:
compiler/make.module_target.m:
Make sure all generated object files are cleaned up.
compiler/prog_io.m:
Add a better message for files which can't be found.
compiler/make.util.m:
Add `.lpic_o' to the list of extensions.
compiler/Mmakefile:
profiler/Mmakefile:
deep_profiler/Mmakefile:
Pass `--linkage shared' to mmc (`--shared' is in MLFLAGS).
tests/Mmakefile:
tests/mmc_make/Mmakefile:
tests/mmc_make/Mercury.options:
tests/mmc_make/complex_test.{m,exp}:
tests/mmc_make/hello.{m,exp}:
Test `mmc --make'.
tests/lib/complex*.m:
The complex numbers library from the extras distribution,
for use in the mmc_make tests.
Estimated hours taken: 28
Branches: main
Change `mmc --make' so that it no longer builds the external foreign
object files at the same time as it builds the target object file.
This allows one to build on the IL backend where building an external
foreign file assembly depends on having all the imported Mercury
assemblies built first.
Various fixes were also added so that `mmc --make --grade il' could make
an executable.
compiler/compile_target_code.m:
Change il_assemble so that we always build a .dll version
irrespective of whether it contains main or not, as MC++ or C#
code may refer to the dll.
Add Mercury/dlls to the search path for the C# and MC++
compilers.
s,/,\\\\,g in the C# filename as the MS C# compiler doesn't
understand / as a directory seperator.
Add the referenced dlls to the C# compilers command line.
Export maybe_pic_object_file_extension.
compiler/handle_options.m:
Fix a bug where copmute_grade incorrectly generated `hl.il'
instead of `il' as the grade name because we weren't always
considering the --target option.
compiler/make.m:
Add to the compilation_task_type type the alternatives
foreign_code_to_object_code and fact_table_foreign_code_file.
Add to the module_target_type type the alternatives
foreign_asm, foreign_object and factt_object.
compiler/make.dependencies.m:
Add code to handle the new module_target_type alternatives.
Add code to build the new alternatives to
compilation_task_type.
compiler/make.module_target.m:
Add rules to build the foreign_code_to_object_code and
fact_table_code_to_object_code.
compiler/make.program_target.m:
Determine the targets needed to be built for all the external
foreign files and add them to build target list.
compiler/make.util.m:
Add code to handle the new module_target_type alternatives.
Change write_target_file to output the correct name when
building the foreign_asm and foreign_object targets.
compiler/modules.m:
Move referenced_dlls into the interface for use by
`compile_target_code.m'.
Don't place dlls in a sub-directory because on the IL backend
the dlls are `part' of the executable file.
Add a `MkDir' argument to fact_table_file_name which
optionally creates a directory to store the generated
file_name in.
tests/hard_coded/foreign_proc_make.exp:
tests/hard_coded/foreign_proc_make.m:
tests/hard_coded/foreign_proc_make2.m:
Add a test case.
Estimated hours taken: 1
Branches: main
With `--make', warn if a target specified on the command line
is already up to date.
compiler/make.util.m:
Check whether a target that was found to be up to date
was specified on the command line.
compiler/make.m:
Add the targets specified on the command line to the make_info.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.dependencies.m:
Call make__util__maybe_warn_up_to_date_target when a target
is found to be up to date.
Remove targets from the list of targets specified on the command
line as they are processed to avoid generating multiple warnings.
compiler/options.m:
doc/user_guide.texi:
Add an option `--no-warn-up-to-date'.
tests/warnings/Mmakefile:
tests/warnings/up_to_date.{m,exp}:
Test case.
Estimated hours taken: 10
Branches: main
Library installation with `mmc --make'.
compiler/make.m:
compiler/make.program_target.m:
Handle `mmc --make lib<module>.install'.
compiler/options.m:
Add an option `--use-grade-subdirs', which causes
all grade-dependenent files to be placed in
`Mercury/<grade>/<ext>s' subdirectories, even
those files that are intended for use by the user.
`--use-grade-subdirs' is not documented because it
is only intended for use in library installation
with `mmc --make' (it doesn't work at all with Mmake).
Documenting it would require documenting (and setting
in stone) the layout of the `Mercury' directory, which
is probably a bad idea.
Mmake.workspace:
compiler/handle_options.m:
scripts/Mmake.rules:
Header files are now always searched for using the plain
file name (not Mercury/mihs/module.mih), so add a
`--c-include-directory' option to search Mercury/mihs
in the current directory.
compiler/modules.m:
compiler/intermod.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile.m:
compiler/mlds_to_c.m:
compiler/trans_opt.m:
Handle `--use-grade-subdirs' in module_name_to_file_name.
Add module_name_to_search_file_name, which should be
used to generate the names of files that might be part
of an installed library. This is needed because installation
and local directory hierarchies have a different layout,
A better long-term fix would be to change things so that
the installation and local directory layouts are the same.
compiler/make.util.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
Add an extra argument to get_target_timestamp and
get_file_name to specify whether the file should
be searched for.
compiler/options_file.m:
scripts/Mmake.vars.in:
Handle the LIBGRADES and INSTALL_PREFIX make variables.
doc/user_guide.texi:
Remove the statement that library installation is
not supported with `mmc --make'.
Estimated hours taken: 3
Branches: main
Fix the handling of header files with `mmc --make'.
compiler/make.module_target.m:
Check that all files made by the command are present
(for example, previously only the `.c_date' files were
checked, not the `.c' files).
compiler/make.util.m:
In high-level C grades, don't rebuild the `.o' file if an
irrelevant part of a `.mih' file has changed. If a relevant
part of a `.mih' file changed, the interface files of the
imported module must have changed in a way that would force
the `.c' and `.o' files of the current module to be rebuilt.
When finding the timestamps for header files, make sure
the current directory is searched.
Header files are created using mercury_update_interface,
so to check whether a header file is up to date we need
to check the timestamp on the `.c_date' or `.s_date' file,
not the header file itself.
compiler/make.dependencies.m:
Add some more debugging messages.
Fix the format of some error messages.
Estimated hours taken: 25
Branches: main
Fix problems with the compiler-generated header files:
1. the header files are grade dependent, but the header files
can only be installed for one grade.
2. the generated header files can clash with system headers.
To solve these problems, the compiler now generates a
grade dependent `.mih' file containing the declarations
needed when a module is imported in a high-level C code
grade, and a grade independent `.mh' file, which contains
the prototypes for `:- pragma export' declarations.
compiler/export.m:
Generate a `.mh' rather than a `.h' file for the `:- pragma export'
declarations.
Allow the header file generated by export.m to be used with
`--high-level-code'.
compiler/modules.m:
library/Mmakefile:
Add a module.install_grade_hdrs target to install the `.mih'
files in a grade-dependent directory.
compiler/arg_info.m:
compiler/hlds_out.m:
compiler/hlds_pred.m:
Make it easier to tell if the arg_info field of the proc_info
has been set.
compiler/mlds_to_c.m:
Include both the `.mh' and `.mih' files for imported modules.
The type used as the return value for a semidet procedure
exported to C is `MR_bool', not `MR_Word'.
compiler/mlds_to_c.m:
compiler/modules.m:
Don't add a `mercury.' prefix to the standard library
header file names. They can't clash with the system
headers any more.
compiler/mercury_compile.m:
compiler/mlds_to_c.m:
Use export.m to generate the header file for `:- pragma export'
declarations even in hlc grades.
compiler/mlds.m:
compiler/ml*.m:
Distinguish between the `.mh' and `.mih' files
in `mlds__import's.
compiler/handle_options.m:
scripts/Mmake.vars.in:
scripts/mgnuc.in:
Add C include directory options for the installed grade
dependent `.mih' files.
Mmakefile:
scripts/Mmake.rules:
s/h/mih/ in the commands to save the grade dependent
files when installing the library grades.
compiler/make.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.util.m:
Handle dependencies on `.mh' and `.mih' files.
NEWS:
doc/user_guide.texi:
Document the change.
Estimated hours taken: 3
Handle `mmc --make lib<module>' target, which builds all the files
required to use a library in the current grade.
compiler/make.m:
Check for `lib<module>' when attempting to classify a target.
compiler/make.program_target.m:
compiler/compile_target_code.m:
Make `.init' files when building the `.a' file.
Invoke the command given by `--pre-link-command' before linking.
compiler/make.module_target.m:
compiler/make.util.m:
Move find_oldest_timestamp into make.util.m for
use by make.program_target.m.
compiler/options.m:
doc/user_guide.texi:
Add an option `--make-init-file-command', to specify an
alternative command to make the `.init' file. This is needed
for the standard library.
Add an option `--pre-link-command', which specifies a
command to be run before linking. This is useful if there
are foreign files which depend on headers produced by
the Mercury compiler.
Estimated hours taken: 2
Branches: main
Don't pass the default options twice when `mmc --make' invokes mmc.
compiler/options.m:
Add an option `--invoked-by-mmc-make', which is passed
to mmc by `mmc --make' to disable reading the default
options and generation of `.d' files.
Remove the `--generate-mmake-module-dependencies' option.
It's functionality is subsumed by `--invoked-by-mmc-make'.
compiler/make.util.m:
Pass `--invoked-by-mmc-make' to mmc.
compiler/mercury_compile.m:
compiler/handle_options.m:
Handle `--invoked-by-mmc-make'.
When computing the option arguments to pass to make__make_targets,
don't include the DEFAULT_MCFLAGS.
Estimated hours taken: 0.25
Branches: main
compiler/compile_target_code.m:
compiler/make.program_target.m:
compiler/make.util.m:
Put the `lib' prefix on the filenames for `.a' and `.so' files.
Estimated hours taken: 15
Branches: main
Make inter-module optimization work properly with sub-modules.
compiler/intermod.m:
Write `exported_to_submodules' predicates to the `.opt' file.
Read `.int0' files needed by the `.opt' files.
compiler/make.dependencies.m:
compiler/modules.m:
Handle dependencies on the extra `.int0' files when compiling
with `--intermodule-optimization'.
compiler/modules.m:
compiler/prog_io.m:
compiler/*.m:
Handle partially qualified file names when searching for
the `.m' file for a module when checking whether there
should be a dependency on the `.opt' file for the module.
Separate out the code to find for the source file for a module
from the code to read the source file for a module.
Remove an unnecessary argument from prog_io__read_opt_file
(`.opt' files are always searched for).
compiler/modules.m:
Export process_module_private_interfaces, for use by intermod.m.
Remove process_module_indirect_imports, which isn't used anywhere.
Change get_ancestors from a predicate to a function.
compiler/make_hlds.m:
Don't report duplicate declaration errors for items imported
for inter-module optimization. Sometimes both the `.int' and
`.int0' file for a module are read, and the `.int0' file contains
everything in the `.int' file..
compiler/modes.m:
compiler/post_typecheck.m:
Don't report errors for duplicate mode declarations for imported
predicates when performing inter-module optimization. If the
`.int' and `.int0' files for a module are both read, the mode
declarations for a predicate can be read twice.
Where there are duplicate mode declarations, remove the
duplicate procedures.
Move the code to check for indistinguishable modes into
post_typecheck.m. It only needs to be done once, not
on every iteration of mode inference.
compiler/hlds_pred.m:
Add a predicate pred_info_remove_procid, for use by post_typecheck.m.
compiler/mercury_to_mercury.m:
Improve the comment generated for module_defn items which shouldn't
appear in Mercury source.
compiler/notes/compiler_design.html:
Improve the documentation of post_typecheck.m.
tests/invalid/qualified_cons_id2.err_exp:
Update expected output.
Estimated hours taken: 1.5
Branches: main
Rearrange some code after the `--make' change. This was not done
as part of that change for ease of reviewing.
compiler/mercury_compile.m:
compiler/compile_target_code.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
Move code to compile the generated code into compile_target_code.m.
compiler/make.util.m:
compiler/passes_aux.m:
compiler/process_util.m:
Move process and signal handling functionality into process_util.m.
compiler/Mmakefile:
Compile process_util.c with `--no-ansi' so that the declarations
of `struct sigaction' and `kill' are available on Linux.
compiler/notes/compiler_design.html:
Document compile_target_code.m and process_util.m.
Move timestamp.m into the "Miscellaneous" section (it's
used by make as well as smart recompilation).
Fix the documentation of options_file.m.
Estimated hours taken: 500
Add an alternative implementation of Mmake as part of the compiler.
The advantages of this are
- more accurate dependencies
- no `mmake depend' step
- less process creation (no processes are created to
build interface files).
Still to do:
- handle --split-c-files
- handle the IL backend properly
- library installation
- allow the compiler to be built and the nightly tests
to be run with `mmc --make'
compiler/make.m:
Control the build process.
compiler/make.program_target.m:
Build executables and libraries.
compiler/make.module_target.m:
Build C files, object files, interface files etc.
compiler/make.dependencies.m:
Work out the depenendencies between targets.
compiler/make.module_dep_file.m:
Record the inter-module dependencies between invocations of mmc.
compiler/make.util.m:
Utility predicates used by `mmc --make'.
compiler/compile_target_code.m:
This module will eventually contain the predicates used
to compile the target code files generated by the compiler
which are now in mercury_compile.m. (That will be done
as a separate change for ease of reviewing).
For now compile_target_code.m
compiler/mercury_compile.m:
Export the predicates used to compile target code.
Call make.m.
Pass the name of the top-level module in the source file to modules.m.
It is needed when generating the `.module_dep' files.
Lookup the option defaults (which will eventually be stored in
DEFAULT_MCFLAGS by the mmc script) before compiling. Up until now
the option defaults have been passed on the command line by the
mmc script, but with `mmc --make' the default options need
to be overridden by the value of the MCFLAGS make variable, but
the MCFLAGS make variable is overridden by command line options.
Pass the value of `--link-flags' to c2init.
Remove some uninformative messages printed when a C, IL, etc.
compilation fails.
compiler/options_file.m:
Read files containing Make style variable assignments.
compiler/options.m:
doc/user_guide.texi:
Add a new options category: build system options.
Add some extra options:
--warn-undefined-options-variables - like mmake --warn-undefined-vars
--verbose-commands - print commands that the user might be
interested in, like C compilation, but not things
like mercury_update_interface.
--output-compile-error-lines - print the first n lines
of the error file generated by a command.
--generate-mmc-make-modules-dependencies - generate dependencies
for use by `mmc --make' even when using Mmake.
--il-assembler, --ilasm-flags, --mcpp-compiler, --mcpp-flags,
--csharp-compiler, --csharp-flags, --install-prefix,
--install-command, --libgrades, --options-files,
--options-search-directories.
compiler/modules.m:
Add fields to the `module_imports' type for use by make.*m.
Don't try to fill in fields of the module_imports structure
lazily. It's error prone, and probably doesn't save much
anyway.
Clean up the code to compute what foreign languages
are used by a list of item.
Simplify the handling of fact tables by recording that a module
containing fact tables has foreign code to implement them,
rather than requiring separate checks everywhere.
Generalise predicates like get_interface so that they
work even after the imported items have been read.
Fix the handling of header files with the LLDS backend.
Install the `.module_dep' files created for use by
`mmc --make'.
compiler/*.m:
Use record syntax rather than explicit deconstruction to
refer to fields of the `module_imports' type.
compiler/*.m:
Be more careful about where output goes.
mercury_compile.m sets the output stream to be io__stderr_stream
at the start of compilation, so remove all explicit writes to
io__stderr_stream (with `--make' the error output stream may be
a `.err' file, not io__stderr_stream).
Change all occurrences of io__tell/io__told to use
io__open_output/io__close_output (io__told restores the current
output stream to io__stdout_stream, not the previous value).
compiler/passes_aux.m:
Make the output from system commands go to the current
output stream, not C stdout and stderr.
Allow commands to be printed with `--verbose-commands'.
Remove uninformative error messages when a command fails.
compiler/timestamp.m:
Add functions oldest_timestamp and newest_timestamp.
compiler/llds_out.m:
Record the number of C files written with `--split-c-files'
in <module>.num_split.
compiler/prog_io.m:
compiler/*.m:
`search_for_file' now returns the directory in which the
file was found.
compiler/foreign.m:
Use sub-typing to make some calls to predicates in this
module `det' rather than `semidet'.
compiler/handle_options.m:
Return the option arguments.
compiler/Mmakefile:
make.util.m refers to kill() and `struct sigaction' which
are not exported from <signal.h> unless `--no-ansi' is
passed to gcc.
compiler/notes/compiler_design.html:
Document the new modules.
runtime/mercury_signal.h:
runtime/mercury_signal.c:
Add a function MR_signal_should_restart() which alters
whether a signal restarts or interrupts system calls.
In general restarting is the preferred behaviour, but
the wait() for a child process needs to be interruptible.
scripts/Mmake.vars.in:
Add subdirs for `.module_dep', `.err_date'
and `.num_split' files.
library/io.m:
Add a version of io_call_system which returns the signal
that killed the command rather than converting it into
an error message.
Add a predicate to interpret the result of system() or wait().
library/list.m:
Add list__map_foldl2 and a unique mode for list__foldl3.
NEWS:
Document the new library predicates.
configure.in:
runtime/mercury_conf.h.in:
Check for siginterrupt().
doc/user_guide.texi:
Document the new options.
Add a description of `mmc --make' to the "Using Mmake" chapter.