[m-rev.] for review: grade specific .init files
Julien Fischer
juliensf at csse.unimelb.edu.au
Wed Nov 22 17:55:08 AEDT 2006
For post-commit review.
Estimated hours taken: 10
Branches: main
A side effect of the introduction of trace goals is that .init files are
now grade dependent. Consider a module that contains the following
trace goal:
trace [ compile_time(grade(debug)),
run_time(env("FOO"))
] (
...
),
In a debug grade the .init file for a library containing that module will
include the following directive:
ENVVAR FOO
In a non-debug grade it won't. At the moment which version of the .init
file is actually installed depends upon which grade was the first to
be built. This can result in linker errors if the wrong grade is used
with the wrong .init file.
There are two possible fixes. (1) always output ENVVAR directives
regardless of whether the compile time conditions of the trace goals to
which they are attached are true or not. (2) build grade specific .init
files and install them in grade specific locations.
The following diff implements the first stage of (2). For each grade in
which a library is to be installed we create a grade specific .init file
and then install it in a grade specific location, e.g.
`$(INSTALL_PREFIX)/lib/mercury/modules/<grade>'. (For bootstrapping
purposes .init files are currently still installed in the old location
as well.)
After this change has been installed on our machines I will add the
second part of this change which modifies the compiler to look for the
.init files in the new grade specific locations. The final part of the
change will then remove support for installing .init files in the old
location.)
scripts/Mmake.vars.in:
Add a variable that holds the name of a grade specific directory
in which to install .init files.
scripts/Mmake.rules:
Add a rule to install the .init files in a grade specific location.
browser/Mmakefile:
mdbcomp/Mmakefile:
runtime/Mmakefile:
Change the dependencies on the library installation targets so
that installing a library causes the .init files to be built and
installed.
(Currently this dependency is on the install target, which means
that the install_init rule is only invoked once, rather than
every time a grade is built.)
Install the .init files for these libraries in grade specific
locations. (For bootstrapping purposes they are currently also
installed in the old location.)
runtime/Mmakefile:
Remove the code that deletes runtime.init if it exists.
(Anyone who has a Mercury installation old enough for this to
be a problem is going to encounter more serious problems than
the runtime being initialized twice.)
Unrelated change: remove some duplicate entries from the list
of header files.
compiler/make.program_target.m:
Have mmc --make install the .init files in a grade specific location.
(They are also still installed in the old location.)
NOTE: the `XXX trace goal fix.' comments are placeholders for
things that need to be changed during the latter stages of this change.
Julien.
Index: browser/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/Mmakefile,v
retrieving revision 1.48
diff -u -r1.48 Mmakefile
--- browser/Mmakefile 16 Dec 2005 05:49:31 -0000 1.48
+++ browser/Mmakefile 22 Nov 2006 05:10:20 -0000
@@ -267,11 +267,14 @@
# Installation targets
.PHONY: install
-install: install_init install_library
+install: install_library
+# XXX Trace goal fix.
.PHONY: install_dirs
install_dirs:
[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
+ [ -d $(INSTALL_GRADE_MODULE_DIR) ] || \
+ mkdir -p $(INSTALL_GRADE_MODULE_DIR)
[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
ifneq ("$(filter il% java%,$(GRADE))","")
@@ -286,12 +289,14 @@
else
+# XXX Trace goal fix.
.PHONY: install_init
install_init: $(BROWSER_LIB_NAME).init install_dirs
cp `vpath_find $(BROWSER_LIB_NAME).init` $(INSTALL_MODULE_DIR)
+ cp `vpath_find $(BROWSER_LIB_NAME).init` $(INSTALL_GRADE_MODULE_DIR)
.PHONY: install_library
-install_library: \
+install_library: install_init \
lib$(BROWSER_LIB_NAME).$A \
lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
install_dirs
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.57
diff -u -r1.57 make.program_target.m
--- compiler/make.program_target.m 15 Nov 2006 08:12:55 -0000 1.57
+++ compiler/make.program_target.m 21 Nov 2006 07:20:08 -0000
@@ -788,6 +788,7 @@
->
globals.io_lookup_string_option(install_prefix, Prefix, !IO),
+ % XXX Trace goal fix.
ModulesDir = Prefix/"lib"/"mercury"/"modules",
module_name_to_file_name(MainModuleName, ".init", no, InitFileName,
!IO),
@@ -1007,15 +1008,29 @@
)
),
+ install_grade_init(GradeDir, ModuleName, InitSucceded, !IO),
+
list.map_foldl2(
install_grade_ints_and_headers(LinkSucceeded, GradeDir),
AllModules, IntsHeadersSucceeded, !Info, !IO),
- Succeeded = bool.and_list([LibsSucceeded | IntsHeadersSucceeded])
+ Succeeded =
+ bool.and_list([LibsSucceeded, InitSucceded | IntsHeadersSucceeded])
;
DirResult = no,
Succeeded = no
).
+ % Install the `.init' file for the current grade.
+ %
+:- pred install_grade_init(string::in, module_name::in, bool::out,
+ io::di, io::uo) is det.
+
+install_grade_init(GradeDir, ModuleName, Succeeded, !IO) :-
+ globals.io_lookup_string_option(install_prefix, Prefix, !IO),
+ GradeModulesDir = Prefix / "lib" / "mercury" / "modules" / GradeDir,
+ module_name_to_file_name(ModuleName, ".init", no, InitFileName, !IO),
+ install_file(InitFileName, GradeModulesDir, Succeeded, !IO).
+
% Install the `.opt', `.analysis' and `.mih' files for the current grade.
%
:- pred install_grade_ints_and_headers(bool::in, string::in, module_name::in,
@@ -1195,7 +1210,10 @@
GradeIncSubdir = LibDir/"lib"/Grade/"inc"/"Mercury",
make_directory(GradeIncSubdir, Result2, !IO),
- Results0 = [Result1, Result2],
+ GradeModuleSubdir = LibDir/"modules"/Grade,
+ make_directory(GradeModuleSubdir, Result3, !IO),
+
+ Results0 = [Result1, Result2, Result3],
make_install_symlink(GradeIncSubdir, "mih", LinkResult0, !IO),
list.map_foldl(make_install_symlink(GradeIntsSubdir),
Index: mdbcomp/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/mdbcomp/Mmakefile,v
retrieving revision 1.9
diff -u -r1.9 Mmakefile
--- mdbcomp/Mmakefile 16 Dec 2005 05:49:40 -0000 1.9
+++ mdbcomp/Mmakefile 22 Nov 2006 05:09:57 -0000
@@ -231,11 +231,14 @@
# Installation targets
.PHONY: install
-install: install_init install_library
+install: install_library
+# XXX Trace goal fix
.PHONY: install_dirs
install_dirs:
[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
+ [ -d $(INSTALL_GRADE_MODULE_DIR) ] || \
+ mkdir -p $(INSTALL_GRADE_MODULE_DIR)
[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
ifneq ("$(filter il% java%,$(GRADE))","")
@@ -250,12 +253,14 @@
else
+# XXX Trace goal fix.
.PHONY: install_init
install_init: $(MDBCOMP_LIB_NAME).init install_dirs
cp `vpath_find $(MDBCOMP_LIB_NAME).init` $(INSTALL_MODULE_DIR)
+ cp `vpath_find $(MDBCOMP_LIB_NAME).init` $(INSTALL_GRADE_MODULE_DIR)
.PHONY: install_library
-install_library: \
+install_library: install_init \
lib$(MDBCOMP_LIB_NAME).$A \
lib$(MDBCOMP_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
all-ints install_dirs
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.134
diff -u -r1.134 Mmakefile
--- runtime/Mmakefile 15 Nov 2006 08:24:42 -0000 1.134
+++ runtime/Mmakefile 22 Nov 2006 06:44:26 -0000
@@ -69,11 +69,9 @@
mercury_overflow.h \
mercury_proc_id.h \
mercury_prof.h \
- mercury_profiling_builtin.h \
mercury_prof_mem.h \
mercury_prof_time.h \
mercury_profiling_builtin.h \
- mercury_reg_workarounds.h \
mercury_regs.h \
mercury_reg_workarounds.h \
mercury_runtime_util.h \
@@ -438,13 +436,17 @@
# installation rules
.PHONY: install
-install: install_headers install_init install_lib
+install: install_headers install_lib
+# XXX Trace goal fix.
+#
.PHONY: install_dirs
install_dirs:
-[ -d $(INSTALL_INC_DIR)/machdeps ] || \
mkdir -p $(INSTALL_INC_DIR)/machdeps
-[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
+ -[ -d $(INSTALL_GRADE_MODULE_DIR) ] || \
+ mkdir -p $(INSTALL_GRADE_MODULE_DIR)
-[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
-[ -d $(INSTALL_CONF_DIR) ] || mkdir -p $(INSTALL_CONF_DIR)
-[ -d $(INSTALL_RECONF_DIR)/runtime ] || \
@@ -497,17 +499,16 @@
cp `vpath_find mercury_conf.h.in` $(INSTALL_RECONF_DIR)/runtime
cp `vpath_find $(MACHHDRS)` $(INSTALL_INC_DIR)/machdeps
+# XXX Trace goal fix.
+#
.PHONY: install_init
install_init: $(RT_LIB_NAME).init install_dirs
cp `vpath_find $(RT_LIB_NAME).init` $(INSTALL_MODULE_DIR)
- # "$(RT_LIB_NAME).init" used to be called "runtime.init".
- # If there is still a version with an old name lying around,
- # then delete it; otherwise the initialization would get done twice.
- rm -f $(INSTALL_MODULE_DIR)/runtime.init
+ cp `vpath_find $(RT_LIB_NAME).init` $(INSTALL_GRADE_MODULE_DIR)
-.PHONY: install_lib install_dirs
+.PHONY: install_lib
install_lib: lib$(RT_LIB_NAME).$A lib$(RT_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
- install_dirs
+ install_dirs install_init
cp `vpath_find lib$(RT_LIB_NAME).$A \
lib$(RT_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
$(INSTALL_MERC_LIB_DIR)
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/scripts/Mmake.rules,v
retrieving revision 1.151
diff -u -r1.151 Mmake.rules
--- scripts/Mmake.rules 15 Nov 2006 08:12:56 -0000 1.151
+++ scripts/Mmake.rules 22 Nov 2006 06:46:57 -0000
@@ -477,14 +477,20 @@
lib%.install_library
$(MMAKE) lib$*.install_grades || { mercury_cleanup_install && exit 1; }
+# XXX Trace goal fix.
+#
.PHONY: lib%.install_init
lib%.install_init: %.init install_lib_dirs
$(INSTALL) `vpath_find $*.init` $(INSTALL_MODULE_DIR)
+.PHONY: lib%.install_grade_init
+lib%.install_grade_init: %.init install_grade_dirs
+ $(INSTALL) `vpath_find $*.init` $(INSTALL_GRADE_MODULE_DIR)
+
.PHONY: lib%.install_library
lib%.install_library: lib%.$A lib%.$(EXT_FOR_SHARED_LIB) \
install_grade_dirs lib%.install_grade_hdrs \
- lib%.install_opts
+ lib%.install_opts lib%.install_grade_init
$(INSTALL) `vpath_find lib$*.$A lib$*.$(EXT_FOR_SHARED_LIB)` \
$(INSTALL_MERC_LIB_DIR)
$(RANLIB) $(RANLIBFLAGS) $(INSTALL_MERC_LIB_DIR)/lib$*.$A
@@ -544,6 +550,8 @@
$(INSTALL_MKDIR) $(INSTALL_GRADE_INC_DIR)
-[ -d $(INSTALL_GRADE_INT_DIR) ] || \
$(INSTALL_MKDIR) $(INSTALL_GRADE_INT_DIR)
+ -[ -d $(INSTALL_GRADE_MODULE_DIR) ] || \
+ $(INSTALL_MKDIR) $(INSTALL_GRADE_MODULE_DIR)
# The following is needed to support the `--use-subdirs' option
-[ -d $(INSTALL_GRADE_INC_DIR)/Mercury ] || \
$(INSTALL_MKDIR) $(INSTALL_GRADE_INC_DIR)/Mercury
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.104
diff -u -r1.104 Mmake.vars.in
--- scripts/Mmake.vars.in 15 Nov 2006 08:12:56 -0000 1.104
+++ scripts/Mmake.vars.in 21 Nov 2006 06:02:12 -0000
@@ -745,6 +745,7 @@
FINAL_INSTALL_MERC_GRADELESS_LIB_DIR = $(FINAL_INSTALL_LIBDIR)/lib
INSTALL_MERC_LIB_DIR = $(INSTALL_LIBDIR)/lib/$(GRADESTRING)
INSTALL_GRADE_INC_DIR = $(INSTALL_LIBDIR)/lib/$(GRADESTRING)/inc
+INSTALL_GRADE_MODULE_DIR = $(INSTALL_LIBDIR)/modules/$(GRADESTRING)
INSTALL_GRADE_INC_SUBDIR = $(INSTALL_GRADE_INC_DIR)/Mercury/mihs
FINAL_INSTALL_MERC_LIB_DIR = $(FINAL_INSTALL_LIBDIR)/lib/$(GRADESTRING)
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list