Commit Graph

15 Commits

Author SHA1 Message Date
Simon Taylor
d4ac368915 If $(EXT_FOR_EXE) is not empty, add a phony target
Estimated hours taken: 0.5
Branches: main

If $(EXT_FOR_EXE) is not empty, add a phony target
`main_module' which depends on `main_module'$(EXT_FOR_EXE)
With this change, the command used to build an executable
is consistent across platforms.

compiler/make.m:
	Assume that a target on the command line which doesn't match
	any other file type is an executable, even if $(EXT_FOR_EXE)
	is not empty.

compiler/modules.m:
	Add the rule.

scripts/Mmake.vars.in:
	Add the name of each of the $(MERCURY_MAIN_MODULES) to
	the list of targets which should be made by `mmc --make'
	if mmake was invoked wih `--use-mmc-make'.
2003-01-28 14:52:00 +00:00
Peter Ross
91e84bb9dd Change `mmc --make' so that it no longer builds the external foreign
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.
2002-12-20 09:47:28 +00:00
Simon Taylor
3fda5cf170 With `--make', warn if a target specified on the command line
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.
2002-10-30 13:32:02 +00:00
Simon Taylor
0577cdcf04 Update the TODO list
Estimated hours taken: 0.1
Branches: main

compiler/make.m:
	Update the TODO list
	- library installation has been implemented
	- the code to compile target code is now in compile_target_code.m
2002-10-28 02:43:26 +00:00
Simon Taylor
f647f928e0 Add some documentation.
Estimated hours taken: 0.25
Branches: main

compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
	Add some documentation.
2002-10-14 06:46:34 +00:00
Simon Taylor
44ef4e118b Library installation with `mmc --make'.
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'.
2002-08-07 13:12:11 +00:00
Simon Taylor
f42325917f Give a better error message for nonexistent modules specified
Estimated hours taken: 0.5
Branches: main

Give a better error message for nonexistent modules specified
in `:- import_module' or `:- include_module' declarations.

compiler/make.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
	Track which module imported or included the module
	currently being processed when generating dependencies,
	and include the name of the importing module in the error
	message generated when a module can't be found.

tests/invalid/Mmakefile:
tests/invalid/nonexistent_import.{m,err_exp}:
	Test case.
2002-07-12 07:31:27 +00:00
Simon Taylor
9406f99f9d Allow tools/bootcheck to be run using `mmake --use-mmc-make'.
Estimated hours taken: 5
Branches: main

Allow tools/bootcheck to be run using `mmake --use-mmc-make'.
The tests don't work yet.

compiler/make.m:
compiler/make.module_target.m:
	Handle targets such as `<module>.cs' and `<module>.ints',
	which are used when building stage 3.

Mmake.common.in:
*/Mmakefile:
*/Mercury.options:
	Add Mercury.options files to pass module-specific flags to
	`mmc --make'.

	Avoid triggering the .DEFAULT rule introduced with `--use-mmc-make'
	for optional files like Mmake.params.

compiler/modules.m:
	Build the interface files when building a library in IL grades,
	for consistency with C grades.

library/Mmakefile:
	Improve performance by removing the dependency on the interface
	files when building the library. The files are now always built
	by the libmer_std target.

	Pass the command to build libmer_std.init to `mmc --make'.

tools/bootcheck:
	Add an option `--use-mmc-make'.

	Copy the Mercury.options files into the stage2 and stage3 directories.

scripts/Mmake.rules:
	Don't include the rules for `.dep' files with `--use-mmc-make'.

	Include the rule for `--convert-to-mercury' even with `--use-mmc-make'.

compiler/Mmakefile:
tools/bootcheck:
tools/binary_step:
	`mmc --make' doesn't handle `<module>_init.c' targets, so
	don't make the `cs' target depend on `top_level_init.c'.
	As far as I can tell, that dependency is only present so
	that the stage2 and stage3 compilers have the same set of
	C files. bootcheck and binary_step now only compare `.c'
	files which are present in the stage3 directory.
2002-06-22 19:16:15 +00:00
Simon Taylor
ac5c98bdaf Fix problems with the compiler-generated header files:
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.
2002-05-30 12:55:23 +00:00
Simon Taylor
d0e8840ab7 Handle `mmc --make lib<module>' target, which builds all the files
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.
2002-05-13 18:22:33 +00:00
Simon Taylor
78495d8b99 Complete the support for building libraries with `mmc --make'.
Estimated hours taken: 2.5
Branches: main

Complete the support for building libraries with `mmc --make'.

compiler/make.m:
compiler/make.module_target.m:
compiler/mercury_compile.m:
compiler/compile_target_code.m:
	Generate the `.pic_o' files needed to build shared libraries.

scripts/mmc.in:
	Add `--pic-object-extension', `--create-archive-command'
	`--create-archive-command-output-flag',
	`--create-archive-commandflags' and `--ranlib-command'
	options to DEFAULT_MCFLAGS.

	Allow DEFAULT_MCFLAGS to be overridden in the environment,
	for consistency with the other *FLAGS variables.
2002-05-06 11:43:56 +00:00
Simon Taylor
b9059c01f6 Check for `.depend' targets (which are ignored) before other targets.
Estimated hours taken: 0.25
Branches: main

compiler/make.m:
	Check for `.depend' targets (which are ignored) before other targets.
	Given a target `module.depend', `mmc --make' was attempting to build
	an executable `module.depend'.
2002-05-01 17:09:18 +00:00
Fergus Henderson
7597790760 Use sub-modules to structure the modules in the Mercury compiler directory.
The main aim of this change is to make the overall, high-level structure
of the compiler clearer, and to encourage better encapsulation of the
major components.

compiler/libs.m:
compiler/backend_libs.m:
compiler/parse_tree.m:
compiler/hlds.m:
compiler/check_hlds.m:
compiler/transform_hlds.m:
compiler/bytecode_backend.m:
compiler/aditi_backend.m:
compiler/ml_backend.m:
compiler/ll_backend.m:
compiler/top_level.m:
	New files.  One module for each of the major components of the
	Mercury compiler.  These modules contain (as separate sub-modules)
	all the other modules in the Mercury compiler, except gcc.m and
	mlds_to_gcc.m.

Mmakefile:
compiler/Mmakefile:
	Handle the fact that the top-level module is now `top_level',
	not `mercury_compile' (since `mercury_compile' is a sub-module
	of `top_level').

compiler/Mmakefile:
	Update settings of *FLAGS-<modulename> to use the appropriate
	nested module names.

compiler/recompilation_check.m:
compiler/recompilation_version.m:
compiler/recompilation_usage.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/recompilation.version.m:
	Convert the `recompilation_*' modules into sub-modules of the
	`recompilation' module.

compiler/*.m:
compiler/*.pp:
	Module-qualify the module names in `:- module', `:- import_module',
	and `:- use_module' declarations.

compiler/base_type_info.m:
compiler/base_type_layout.m:
	Deleted these unused empty modules.

compiler/prog_data.m:
compiler/globals.m:
	Move the `foreign_language' type from prog_data to globals.

compiler/mlds.m:
compiler/ml_util.m:
compiler/mlds_to_il.m:
	Import `globals', for `foreign_language'.

Mmake.common.in:
trace/Mmakefile:
runtime/Mmakefile:
	Rename the %.check.c targets as %.check_hdr.c,
	to avoid conflicts with compiler/recompilation.check.c.
2002-03-20 12:37:56 +00:00
Simon Taylor
a719e74ee9 Rearrange some code after the `--make' change.
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.
2002-03-18 04:44:16 +00:00
Simon Taylor
9c9601808d Add an alternative implementation of Mmake as part of the compiler.
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.
2002-03-12 16:33:37 +00:00