Files
mercury/browser/Mmakefile
Simon Taylor 9dd11b2fc6 Smart recompilation. Record version numbers for each item
Estimated hours taken: 400

Smart recompilation. Record version numbers for each item
in interface files. Record which items are used in each compilation.
Only recompile a module if the output file does not exist or
nothing has changed.

There is still some work to do on this:
- it doesn't work with inter-module optimization.
- it doesn't work when the module name doesn't match the file name.
  (this problem will go away when mmake functionality is moved into
  the compiler.

I'll hold off documenting this change in the NEWS file and
on the web page for a month or so, until I've had a bit more
experience using it.

compiler/options.m:
compiler/handle_options.m:
doc/user_guide.texi:
	Add an option `--smart-recompilation', currently off by default.

	Add an internal option `--generate-version-numbers' to control
	whether version numbers are written to the interface files. If
	`--smart-recompilation' is disabled because the module
	is being compiled with `--intermodule-optimization' (e.g. in the
	standard library), we still want to write the version numbers
	to the interface files.

	Add an option `--verbose-recompilation' (default off)
	to write messages describing why recompilation is needed.

	Add an option `--warn-smart-recompilation' (default on)
	to control warnings relating to the smart recompilation
	system. Warn if smart recompilation will not work with
	the output and inter-module optimization options given.

compiler/recompilation.m:
	Type declarations for smart recompilation.
	Predicates to record program items used by compilation.

compiler/recompilation_version.m:
	Compute version numbers for program items in interface files.

compiler/recompilation_usage.m:
	Find all items used by a compilation.

compiler/recompilation_check.m:
	Check whether recompilation is necessary.

compiler/timestamp.m:
	Timestamp ADT for smart recompilation.

compiler/mercury_compile.m:
	Invoke the smart recompilation passes.

compiler/modules.m:
compiler/prog_io.m:
	Return timestamps for modules read.

	When reading a module make sure the current input stream
	is reset to its old value, not stdin.

	Handle version number items in interface files.

compiler/module_qual.m:
compiler/unify_proc.m:
compiler/make_hlds.m:
	Record all items used by local items.

compiler/make_hlds.m:
	Process `:- pragma type_spec' declarations in
	add_item_list_clauses. The qual_info is needed
	when processing `:- pragma type_spec' declarations
	so that any equivalence types used by the declaration
	can be recorded as used by the predicate or function to
	which the `:- pragma type_spec' applies.

compiler/equiv_type.m:
	For each imported item, record which equivalence types
	are used by that item.

compiler/hlds_module.m:
	Add a field to the module_info to store information about
	items used during compilation of a module.

compiler/check_typeclass.m:
	Make sure any items used in clauses for typeclass method
	implementations are recorded in the `.used' file.

compiler/prog_data.m:
compiler/*.m:
	Factor out some duplicated code by combining the
	pred and func, and pred_mode and func_mode items.

	Make it easier to extract the name of a type, inst or mode
	from its declaration.

	Add an item type to hold the version numbers for an interface file.

	Allow warnings to be reported for `nothing' items (used for
	reporting when version numbers are written using an
	obsolete format).

compiler/prog_io.m:
compiler/prog_io_util.m:
compiler/typecheck.m:
compiler/type_util.m:
compiler/*.m:
	Strip contexts from all types, not just those in class constraints.
	This makes it possible to use ordinary unification to check
	whether items have changed (with the exception of clauses).

	Remove code to create types with contexts in typechecking.

	Remove code scattered through the compiler to remove contexts
	from types in class constraints.

compiler/hlds_pred.m:
compiler/prog_util.m:
	Move hlds_pred__adjust_func_arity to prog_util, so that it
	can be used by the pre-hlds passes.

compiler/typecheck.m:
compiler/hlds_module.m:
	Move typecheck__visible_modules to hlds_module.m, so it can
	be used by recompilation_usage.m.

compiler/typecheck.m:
	Add a comment telling where updates may be required if the
	code to typecheck a var-functor unification changes.

compiler/error_util.m:
	Allow writing messages without contexts (used for the verbose
	recompilation messages).

	Add functions to format sym_name and sym_name_and_arity,
	and to add punctuation to the end of an error message
	without unwanted line breaks before the punctuation.

scripts/Mmake.rules:
compiler/modules.m:
	Don't remove the output file before running the compiler. We need
	to leave the old output file intact if smart recompilation detects
	that recompilation is not needed.

compiler/notes/compiler_design.html:
	Document the new modules.

library/io.m:
NEWS:
	Add predicates to find the modification time of files
	and input_streams.

library/set.m:
NEWS:
	Add a predicate version of set__fold

	Don't sort the output of set__filter, it's already sorted.

library/std_util.m:
NEWS:
	Add a predicate `std_util__map_maybe/3' and a function
  	`std_util__map_maybe/2' to apply a predicate or a function to
    	a value stored in a term of type `std_util__maybe'.

configure.in:
runtime/mercury_conf.h.in:
runtime/RESERVED_MACRO_NAMES:
	When checking whether the compiler is recent enough, check for
	the --warn-smart-recompilation option.

	Check for stat().

library/Mmakefile:
	Disable warnings about smart recompilation not working with
	`--intermodule-optimization'.

browser/Mmakefile:
	Disable warnings about smart recompilation not working when
	the module name doesn't match the file name.

runtime/mercury_string.h:
	Add a macro MR_make_string_const() which automates computation
	of the length of string argument to MR_string_const().

tests/recompilation/Mmakefile:
tests/recompilation/runtests:
tests/recompilation/test_functions:
tests/recompilation/TESTS:
tests/recompilation/README:
	A framework for testing smart recompilation.
	The option currently only works for the recompilation directory.

tests/recompilation/TEST.m.{1,2}:
tests/recompilation/TEST_2.m.{1,2}:
tests/recompilation/TEST.exp.{1,2}:
tests/recompilation/TEST.err_exp.2:
	Test cases, where TEST is one of add_constructor_r, add_instance_r,
	add_instance_2_r, add_type_nr, change_class_r, change_instance_r,
	change_mode_r, field_r, func_overloading_nr, func_overloading_r,
	lambda_mode_r, nested_module_r, no_version_numbers_r,
	pragma_type_spec_r, pred_ctor_ambiguity_r, pred_overloading_r,
	add_type_re, remove_type_re, type_qual_re.

tests/handle_options:
	Add an option `-e' to generate any missing expected output files.
2001-06-27 05:05:21 +00:00

208 lines
5.8 KiB
Plaintext

#-----------------------------------------------------------------------------#
# Copyright (C) 1998-2001 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public License - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
# browser/Mmakefile - this is the Mmakefile for building the Mercury
# browser library, which also includes other functionality needed
# by Mercury debuggers.
# Since the code in this directory is intended to be invoked only from
# the trace library, which turns off tracing in the Mercury code it calls,
# compiling the modules in this directory with tracing on only makes
# the generated code much bigger. However, since all Mercury code
# in an executable must be of the same grade, we need to be able to
# compile the modules in this directory in debug grades as well.
MERCURY_DIR=..
include $(MERCURY_DIR)/Mmake.common
MAIN_TARGET=library
VPATH=$(LIBRARY_DIR)
#-----------------------------------------------------------------------------#
# Specify which compilers to use to compile the library.
# Don't change these without good reason - if you want to
# do a temporary change, change ../Mmake.params.
M_ENV = MERCURY_INT_DIR=$(LIBRARY_DIR) \
MERCURY_ALL_C_INCL_DIRS="\
-I$(TRACE_DIR) \
-I$(LIBRARY_DIR) \
-I$(RUNTIME_DIR) \
-I$(BOEHM_GC_DIR) \
-I$(BOEHM_GC_DIR)/include \
"
MCD = $(M_ENV) $(MC) --generate-dependencies
MCI = $(M_ENV) $(MC) --make-interface
MCPI = $(M_ENV) $(MC) --make-private-interface
MCSI = $(M_ENV) $(MC) --make-short-interface
MCOI = $(M_ENV) $(MC) --make-opt-int
MCTOI = $(M_ENV) $(MC) --make-trans-opt
MCG = $(M_ENV) $(MC) --compile-to-c
MCS = $(M_ENV) $(MC) --split-c-files -c --cflags "$(ALL_CFLAGS)"
MGNUC = $(M_ENV) $(SCRIPTS_DIR)/mgnuc
MGNUCFLAGS = $(DLL_CFLAGS)
LDFLAGS = -L$(LIBRARY_DIR) -L$(RUNTIME_DIR) -L$(BOEHM_GC_DIR)
LDLIBS = -l$(STD_LIB_NAME) -l$(RT_LIB_NAME) \
` case "$(GRADE)" in \
*.par*.gc*.prof*) echo "-lpar_gc_prof" ;; \
*.par*.gc*) echo "-lpar_gc" ;; \
*.gc*.prof*) echo "-lgc_prof" ;; \
*.gc*) echo "-lgc" ;; \
esac \
`
# XXX Smart recompilation currently doesn't work when the module
# name doesn't match the file name, so disable warnings about it
# not working in this directory.
MCFLAGS += --no-warn-smart-recompilation
MTAGS = $(SCRIPTS_DIR)/mtags
#-----------------------------------------------------------------------------#
# Stuff for Windows DLLS using gnu-win32
ifeq ($(USE_DLLS),yes)
DLL_CFLAGS = -Dlib$(BROWSER_LIB_NAME)_DEFINE_DLL
include $(MERCURY_DIR)/Makefile.DLLs
else
DLL_CFLAGS =
DLL_DEF_LIB =
endif
#-----------------------------------------------------------------------------#
# targets
.PHONY: all
all : library browse_test declarative_test
.PHONY: depend
depend : mdb.depend browse_test.depend declarative_test.depend
.PHONY: check
check : mdb.check
.PHONY: all-ints
all-ints: ints int3s
.PHONY: ints
ints : mdb.ints browse_test.ints declarative_test.ints
.PHONY: int3s
int3s : mdb.int3s
#-----------------------------------------------------------------------------#
tags : $(MTAGS) $(mdb.ms)
$(MTAGS) $(mdb.ms) ../library/*.m
mdb.stats : $(COMPILER_DIR)/source_stats.awk $(mdb.ms)
awk -f $(COMPILER_DIR)/source_stats.awk \
`vpath_find $(mdb.ms)` > $@
#-----------------------------------------------------------------------------#
.PHONY: dates
dates :
touch $(mdb.dates)
#-----------------------------------------------------------------------------#
.PHONY: os cs ss
os: $(mdb.os)
cs: $(mdb.cs)
ss: $(mdb.ss)
#-----------------------------------------------------------------------------#
.PHONY: library
library: lib$(BROWSER_LIB_NAME).$A lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB)
library: $(BROWSER_LIB_NAME).init
lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).$A : $(mdb.os)
rm -f lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).$A
$(AR) $(ALL_ARFLAGS) \
$(AR_LIBFILE_OPT)lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).$A \
$(mdb.os)
$(RANLIB) lib$(BROWSER_LIB_NAME)$(DLL_DEF_LIB).$A
RPATH_1=$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_LIB_DIR)
RPATH_2=$(SHLIB_RPATH_SEP)$(FINAL_INSTALL_MERC_GC_LIB_DIR)
lib$(BROWSER_LIB_NAME).so : $(mdb.pic_os)
$(LINK_SHARED_OBJ) $(ERROR_UNDEFINED) \
-o lib$(BROWSER_LIB_NAME).so \
$(mdb.pic_os) \
$(RPATH_1)$(RPATH_2) \
$(LDFLAGS) $(LDLIBS) \
$(SOCKET_LIBRARY) $(NSL_LIBRARY) $(DL_LIBRARY) \
$(READLINE_LIBRARIES) \
$(SHARED_LIBS)
$(BROWSER_LIB_NAME).init: $(deps_subdir)mdb.dep mdb.init
cp mdb.init $(BROWSER_LIB_NAME).init
# Ensure we recompile mdb__version if VERSION is changed.
$(os_subdir)mdb.o \
$(os_subdir)mdb.pic_o \
: $(RUNTIME_DIR)/mercury_conf.h
#-----------------------------------------------------------------------------#
realclean_local:
rm -f lib$(BROWSER_LIB_NAME).$A lib$(BROWSER_LIB_NAME).so \
$(BROWSER_LIB_NAME).init mdb.init
rm -f tags
#-----------------------------------------------------------------------------#
# Installation targets
.PHONY: install
install: install_init install_library
.PHONY: install_dirs
install_dirs:
[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
ifeq ($(findstring il,$(GRADE)),il)
# there is no browser in the .NET backend
.PHONY: install_init
install_init:
.PHONY: install_library
install_library:
else
.PHONY: install_init
install_init: $(BROWSER_LIB_NAME).init install_dirs
cp `vpath_find $(BROWSER_LIB_NAME).init` $(INSTALL_MODULE_DIR)
.PHONY: install_library
install_library: lib$(BROWSER_LIB_NAME).$A \
lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB) install_dirs
cp `vpath_find lib$(BROWSER_LIB_NAME).$A \
lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
$(INSTALL_MERC_LIB_DIR)
endif