Files
mercury/Mmake.workspace
Fergus Henderson 17d5aa732e Add support for interfacing Mercury with the MPS garbage collector.
Estimated hours taken: 20
Branches: main

Add support for interfacing Mercury with the MPS garbage collector.

This change is broken into three parts:

	1. Import version 1.100.1 of the MPS kit into the Mercury
	   CVS repository, in the directory `mps_gc'.

	2. Make some changes to the MPS kit for Mercury,
	   to support fully-conservative collection and tagged pointers,
	   and to wrap it in an interface that is similar to that of
	   the Boehm collector.

	3. Modify the rest of the Mercury implementation
	   to support linking with the MPS kit instead
	   of the Boehm collector.  This involved defining
	   `mps' as a new GC method and a new grade component.

This is part 3 of 3.

Mmake.workspace:
	Include the MPS directories in the header file and library search
	paths.

tools/bootcheck:
	Link the mps_gc directory into the stage2 and stage3 directories.

Mmake.workspace:
runtime/Mmakefile:
scripts/ml.in:
	For *.mps grades, link in mps.a.
	(XXX ml.in is linking in libmps.a, which is wrong.)

runtime/Mmakefile:
trace/Mmakefile:
	In the rule for `check_headers', which checks macro namespace
	cleanliness, allow names to start with `MPS_' or `mps_'.

runtime/RESERVED_MACRO_NAMES:
	Add `mercury_mps_h', which is used by mps_gc/code/mercury_mps.h
	for its header guard.  (Normally it would be better to use
	uppercase for header guard macro names, but that would be
	inconsistent with the coding style used in mps_gc/code.)

scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade.sh-subr:
	Handle the new `mps' GC method and grade component.

compiler/globals.m:
compiler/options.m:
doc/user_guide.texi:
	Replace gc_method `conservative' with two alternatives
	`boehm' and `mps'. ("--gc conservative" is still allowed,
	and treated as equivalent to "--gc boehm".)
	Add new function `gc_is_conservative' to globals.m.

compiler/mercury_compile.m:
compiler/handle_options.m:
	Use `gc_is_conservative' rather than `= conservative'.

compiler/handle_options.m:
	Handle the "mps" grade component.
	(XXX need to document this in options.m and user_guide.texi)

compiler/compile_target_code.m:
	Pass the appropriate C defines for the new GC methods.

compiler/mercury_compile.m:
	Wrap the work-around for a Boehm GC bug inside `#ifndef MR_MPS_GC'.

library/array.m:
	Use GC_FREE() rather than GC_free().
	This is needed for two reasons:
	- so that it works with MPS, which only defines GC_FREE
	- so that it works with then Boehm collector when
	  GC debugging is enabled

library/benchmarking.m:
	Output GC statistics for the MPS collector.

runtime/mercury.h:
runtime/mercury_heap.h:
runtime/mercury_init.h:
runtime/mercury_memory.h:
	If MR_MPS_GC is defined, use mercury_mps.h rather than gc.h.

runtime/mercury_conf_param.h:
	Add configuration macros MR_BOEHM_GC and MR_MPS_GC.
	Set MR_CONSERVATIVE_GC if either of these is set.
	Default to MR_BOEHM_GC if only MR_CONSERVATIVE_GC is set.

runtime/mercury_context.h:
runtime/mercury_deep_copy.h:
runtime/mercury_engine.h:
runtime/mercury_float.h:
runtime/mercury_heap.h:
	Explictly #include "mercury_conf.h", so that
	MR_CONSERVATIVE_GC will be set properly before it is tested.

runtime/mercury_grade.h:
	Handle the .mps grade component.

runtime/mercury_memory.c:
runtime/mercury_wrapper.c:
runtime/mercury_memory_handlers.c:
	Move the call to MR_setup_signals() earlier in the
	initialization sequence, so that the MPS signal handlers
	get installed after our signal handlers.  This is needed
	because our signal handlers assume that any signals that
	they can't handle are fatal errors, which interfere's
	with MPS's use of signal handlers for memory barriers.

runtime/mercury_wrapper.c:
	Add code to initialize the MPS collector.
	Put code which is specific to the Boehm collector inside
	#ifdef MR_BOEHM_GC rather than #ifdef MR_CONSERVATIVE_GC.

runtime/mercury_wrapper.h:
	Update a comment.
2002-08-21 11:28:01 +00:00

205 lines
6.6 KiB
Plaintext

#-----------------------------------------------------------------------------#
# Copyright (C) 2002 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public Licence - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
# Mmake.workspace - build a program or library using the current workspace,
# not an installed library.
#
# The variable WORKSPACE must be set externally.
#
# If the variable LINK_STATIC is set to `yes', the names of the `.a' files
# for the Mercury libraries will be included in MLLIBS, otherwise
# `-l' options will be included.
#
# By default, if LINK_STATIC is unset or set to `no', `-R' options
# will be passed to ml for each of the directories containing the
# Mercury libraries. If SET_RPATH is set to `no', these options will
# not be passed. This is useful for building the Mercury libraries,
# for which the rpath must be set in each Mmakefile to point to
# the installed library directory.
#
# Setting LINK_BOEHM_GC_ONLY to `yes' causes only the boehm_gc directory
# (and/or the mps_gc directory) to be included in MLFLAGS, MLLIBS and CFLAGS.
# Setting LINK_RUNTIME_ONLY to `yes' causes only the *_gc and runtime
# directories to be included in MLFLAGS, MLLIBS and CFLAGS.
# Setting LINK_STDLIB_ONLY to `yes' causes only the *_gc, runtime
# and library directories to be included in MLFLAGS, MLLIBS and CFLAGS.
#-----------------------------------------------------------------------------#
ifeq ($(origin LINK_STATIC),undefined)
LINK_STATIC = no
endif
ifeq ($(origin SET_RPATH),undefined)
SET_RPATH = yes
endif
ifeq ($(origin LINK_BOEHM_GC_ONLY),undefined)
LINK_BOEHM_GC_ONLY = no
endif
ifeq ($(origin LINK_RUNTIME_ONLY),undefined)
LINK_RUNTIME_ONLY = no
endif
ifeq ($(origin LINK_STDLIB_ONLY),undefined)
LINK_STDLIB_ONLY = no
endif
SCRIPTS_DIR = $(WORKSPACE)/scripts
RUNTIME_DIR = $(WORKSPACE)/runtime
LIBRARY_DIR = $(WORKSPACE)/library
TRACE_DIR = $(WORKSPACE)/trace
BROWSER_DIR = $(WORKSPACE)/browser
BOEHM_GC_DIR = $(WORKSPACE)/boehm_gc
MPS_GC_DIR = $(WORKSPACE)/mps_gc/code
COMPILER_DIR = $(WORKSPACE)/compiler
UTIL_DIR = $(WORKSPACE)/util
# Specify the MPS "platform"
# E.g. lii4gc means Linux, i486, gcc
MPS_PFM = lii4gc
# Specify the MPS "variety"
# E.g. "hi" means "hot internal" (production version),
# "ci" means "cold internal" (version with extra debugging checks)
MPS_VARIETY = hi
MPS_GC_OBJ_DIR=$(MPS_GC_DIR)/$(MPS_PFM)/$(MPS_VARIETY)
# The names of the various libraries.
# The archives and shared object objects have a "lib" prefix and a ".a" or
# ".so" (or ".dll") suffix around these names; the initialization files
# have just a ".init" suffix. (The trace library does not have a .init file,
# since it contains no Mercury code.)
#
# If you change these, you will also need to change scripts/ml.in,
# scripts/c2init.in, tools/bootcheck, tools/binary, tools/binary_step
# and tools/linear.
RT_LIB_NAME = mer_rt
STD_LIB_NAME = mer_std
TRACE_LIB_NAME = mer_trace
BROWSER_LIB_NAME = mer_browser
# This specifies the path to the so_locations file (or its equivalent),
# which is used by the linker to help it to map different shared objects
# to different virtual memory addresses at static link time, so as to avoid
# the need to relocate them at dynamic link time.
SO_LOCATIONS_DIR = $(WORKSPACE)/
export SO_LOCATIONS_DIR
MC = $(SCRIPTS_DIR)/mmc
MGNUC = $(SCRIPTS_DIR)/mgnuc
ML = $(SCRIPTS_DIR)/ml
C2INIT = MERCURY_MKINIT=$(UTIL_DIR)/mkinit $(SCRIPTS_DIR)/c2init
MTAGS = $(SCRIPTS_DIR)/mtags
MTAGSFLAGS += $(EXTRA_MTAGSFLAGS)
VPATH = $(LIBRARY_DIR)
ifeq ($(MMAKE_USE_MMC_MAKE),yes)
MCFLAGS += --options-file $(WORKSPACE)/Mercury.options
endif
MCFLAGS += --no-mercury-stdlib-dir -I$(LIBRARY_DIR)
MGNUCFLAGS += --no-mercury-stdlib-dir
C2INITFLAGS += --trace-init-file $(BROWSER_DIR)/$(BROWSER_LIB_NAME).init
C2INITARGS += $(LIBRARY_DIR)/$(STD_LIB_NAME).init \
$(RUNTIME_DIR)/$(RT_LIB_NAME).init
MLFLAGS += --no-mercury-stdlib-dir
#
# Work out the C include directories.
#
C_INCL_DIRS = -I$(BOEHM_GC_DIR) -I$(BOEHM_GC_DIR)/include -I$(MPS_GC_DIR)
ifneq ($(LINK_BOEHM_GC_ONLY),yes)
C_INCL_DIRS += -I$(RUNTIME_DIR)
ifneq ($(LINK_RUNTIME_ONLY),yes)
C_INCL_DIRS += -I$(LIBRARY_DIR) -I$(LIBRARY_DIR)/$(mihs_subdir)
ifneq ($(LINK_STDLIB_ONLY),yes)
C_INCL_DIRS += -I$(BROWSER_DIR) -I$(BROWSER_DIR)/$(mihs_subdir) -I$(TRACE_DIR)
endif
endif
endif
CFLAGS += $(C_INCL_DIRS)
MCFLAGS += $(C_INCL_DIRS:-I%=--c-include-directory %)
#
# Work out which libraries to link with.
# The $(shell) here is needed to allow the variable values in
# ECHO_MERCURY_OPTIONS in Mmake.vars to be single-quoted when
# passed to echo in order to preserve double-quotes (e.g. for
# file names containing spaces).
#
STATIC_GC_LIBS_0 = \
` \
case $(GRADE) in \
*.par*.gc*.prof*) echo $(BOEHM_GC_DIR)/libpar_gc_prof.$A ;; \
*.par*.gc*) echo $(BOEHM_GC_DIR)/libpar_gc.$A ;; \
*.gc*.prof*) echo $(BOEHM_GC_DIR)/libgc_prof.$A ;; \
*.gc*) echo $(BOEHM_GC_DIR)/libgc.$A ;; \
*.mps*) echo $(MPS_GC_OBJ_DIR)/mps.$A ;; \
esac \
`
STATIC_GC_LIBS = $(shell echo $(STATIC_GC_LIBS_0))
SHARED_GC_LIBS_0 = \
` \
case $(GRADE) in \
*.par*.gc*.prof*) echo -lpar_gc_prof ;; \
*.par*.gc*) echo -lpar_gc ;; \
*.gc*.prof*) echo -lgc_prof ;; \
*.gc*) echo -lgc ;; \
*.mps*) echo $(MPS_GC_OBJ_DIR)/mps.$A ;; \
esac \
`
SHARED_GC_LIBS = $(shell echo $(SHARED_GC_LIBS_0))
ifeq ($(LINK_STATIC),yes)
STATIC_RT_LIBS=
STATIC_STD_LIBS=
STATIC_TRACE_LIBS=
ifneq ($(LINK_BOEHM_GC_ONLY),yes)
STATIC_RT_LIBS = $(RUNTIME_DIR)/lib$(RT_LIB_NAME).$A
ifneq ($(LINK_RUNTIME_ONLY),yes)
STATIC_STD_LIBS = $(LIBRARY_DIR)/lib$(STD_LIB_NAME).$A
ifneq ($(LINK_STDLIB_ONLY),yes)
STATIC_TRACE_LIBS = $(TRACE_DIR)/lib$(TRACE_LIB_NAME).$A \
$(BROWSER_DIR)/lib$(BROWSER_LIB_NAME).$A
endif
endif
endif
MLOBJS += $(STATIC_TRACE_LIBS) $(STATIC_STD_LIBS) \
$(STATIC_RT_LIBS) $(STATIC_GC_LIBS)
else # LINK_STATIC != yes
LINK_RT_LIB_OPTS=
LINK_STD_LIB_OPTS=
LINK_TRACE_LIB_OPTS=
ifneq ($(LINK_BOEHM_GC_ONLY),yes)
LINK_RT_LIB_OPTS = -l$(RT_LIB_NAME)
ifneq ($(LINK_RUNTIME_ONLY),yes)
LINK_STD_LIB_OPTS = -l$(STD_LIB_NAME)
ifneq ($(LINK_STDLIB_ONLY),yes)
LINK_TRACE_LIB_OPTS = -l$(TRACE_LIB_NAME) -l$(BROWSER_LIB_NAME)
endif
endif
endif
LINK_LIB_OPTS = $(LINK_TRACE_LIB_OPTS) $(LINK_STD_LIB_OPTS) \
$(LINK_RT_LIB_OPTS) $(SHARED_GC_LIBS)
LIB_DIR_OPTS = -L$(BOEHM_GC_DIR) -L$(MPS_GC_DIR) -L$(RUNTIME_DIR) \
-L$(LIBRARY_DIR) -L$(TRACE_DIR) -L$(BROWSER_DIR)
MLFLAGS += $(LIB_DIR_OPTS)
MLLIBS += $(LINK_LIB_OPTS)
ifeq ($(SET_RPATH),yes)
MLFLAGS += $(LIB_DIR_OPTS:-L%=-R%)
endif
endif # LINK_STATIC != yes