[m-rev.] for review: library additions for erlang

Peter Wang wangp at students.csse.unimelb.edu.au
Wed Aug 8 16:46:50 AEST 2007


On 2007-08-08, Peter Wang <wangp at students.csse.unimelb.edu.au> wrote:
> On 2007-08-06, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> > 
> >  On Mon, 6 Aug 2007, Peter Wang wrote:
> > 
> > > On 2007-08-06, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> > >>
> > >>> %-----------------------------------------------------------------------------%
> > >>> %-----------------------------------------------------------------------------%
> > >>>
> > >>> :- module erlang_conf.
> > >>> :- implementation.
> > >>>
> > >>> :- pragma foreign_decl("Erlang", "
> > >>> -define(MR_VERSION, ""@VERSION@"").
> > >>> -define(MR_FULLARCH, ""@FULLARCH@"").
> > >>> ").
> > >>
> > >>  Does the source distribution still work with this change?
> > >>  (It there is *not* already a Mercury compiler installed.)
> > >
> > > No, the library/erlang_conf.m.in file isn't in the tarball for some reason.
> > 
> >  If you committed that change around the time that Ralph committed the
> >  pretty printer, there probably hasn't been a new one built since then
> >  since the nightly builds were broken - that's why it may not be in there.
> 
> That turned out to be it.  library/erlang_conf.m also exists.  Should
> the realclean_local target in the library directory delete it?
> 

Julien pointed out that the problem is if configure generates/touches
erlang_conf.m then make would try to use an installed Mercury compiler
to build the .c file.

Here is a proposed fix.


Estimated hours taken: 0.5
Branches: main

Don't generate library/erlang_conf.m with configure as that introduces a
bootstrapping problem -- if a .m file is generated then an installed Mercury
compiler is required to generate .c files from it.  Instead, generate a .hrl
header file which is only included when building for the Erlang backend.

configure.in:
library/library.hrl.in:
	Generate erlang_conf.hrl instead of erlang_conf.m.

library/library.m:
	Make the Erlang implementation of library.version use the macros from
	erlang_conf.hrl.

	Prevent library.version from being inlined into other modules as that
	would require us to install erlang_conf.hrl for no gain.

	Remove references to erlang_conf.m.

library/Mmakefile:
	Clean erlang_conf.hrl with the realclean_local target.

library/erlang_conf.m.in:
	Delete this.


Index: configure.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.496
diff -u -r1.496 configure.in
--- configure.in	3 Aug 2007 02:30:38 -0000	1.496
+++ configure.in	8 Aug 2007 05:57:44 -0000
@@ -4570,7 +4570,7 @@
 bindist/bindist.INSTALL bindist/bindist.Makefile
 tools/lmc tools/dotime runtime/mercury_dotnet.cs java/runtime/Constants.java
 java/runtime/Native.java
-library/erlang_conf.m
+library/erlang_conf.hrl
 compiler/COMP_FLAGS
 library/LIB_FLAGS
 mdbcomp/MDBCOMP_FLAGS
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.150
diff -u -r1.150 Mmakefile
--- library/Mmakefile	20 Jul 2007 01:22:04 -0000	1.150
+++ library/Mmakefile	8 Aug 2007 06:33:24 -0000
@@ -445,6 +445,7 @@
 	rm -f mr_int.class mr_float.class mr_char.class
 	rm -f mr_int\$$*.class mr_float\$$*.class mr_char\$$*.class
 	rm -f $(JARS) $(NATIVE_SO)
+	rm -f erlang_conf.hrl
 
 #-----------------------------------------------------------------------------#
 
Index: library/erlang_conf.hrl.in
===================================================================
RCS file: library/erlang_conf.hrl.in
diff -N library/erlang_conf.hrl.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ library/erlang_conf.hrl.in	8 Aug 2007 06:15:15 -0000
@@ -0,0 +1,26 @@
+% @configure_input@
+%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%-----------------------------------------------------------------------------%
+% Copyright (C) 2007 The University of Melbourne.
+% This file may only be copied under the terms of the GNU Library General
+% Public License - see the file COPYING.LIB in the Mercury distribution.
+%-----------------------------------------------------------------------------%
+%
+% File: erlang_conf.hrl.in.
+%
+% At the moment this file just stores the library version for Erlang.
+%
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
+-ifndef(MERCURY__ERLANG_CONF_HRL).
+-define(MERCURY__ERLANG_CONF_HRL, 1).
+
+-define(MR_VERSION, "@VERSION@").
+-define(MR_FULLARCH, "@FULLARCH@").
+
+-endif.
+
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
Index: library/erlang_conf.m.in
===================================================================
RCS file: library/erlang_conf.m.in
diff -N library/erlang_conf.m.in
--- library/erlang_conf.m.in	3 Aug 2007 02:30:40 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,26 +0,0 @@
-% @configure_input@
-%-----------------------------------------------------------------------------%
-% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
-%-----------------------------------------------------------------------------%
-% Copyright (C) 2007 The University of Melbourne.
-% This file may only be copied under the terms of the GNU Library General
-% Public License - see the file COPYING.LIB in the Mercury distribution.
-%-----------------------------------------------------------------------------%
-%
-% File: erlang_conf.m.in.
-%
-% At the moment this file just stores the library version for Erlang.
-%
-%-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
-
-:- module erlang_conf.
-:- implementation.
-
-:- pragma foreign_decl("Erlang", "
--define(MR_VERSION, ""@VERSION@"").
--define(MR_FULLARCH, ""@FULLARCH@"").
-").
-
-%-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
Index: library/library.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/library.m,v
retrieving revision 1.112
diff -u -r1.112 library.m
--- library/library.m	3 Aug 2007 05:18:38 -0000	1.112
+++ library/library.m	8 Aug 2007 06:03:24 -0000
@@ -146,7 +146,6 @@
 % NOTE: changes to this list may need to be reflected in mdbcomp/prim_data.m.
 %
 :- import_module erlang_builtin.
-:- import_module erlang_conf.
 :- import_module erlang_rtti_implementation.
 :- import_module mutvar.
 :- import_module par_builtin.
@@ -163,6 +162,11 @@
 % at configuration time, because that would cause bootstrapping problems --
 % we might not have a Mercury compiler around to compile library.m with.
 
+% We can't allow library.version to inlined into other modules.  The Erlang
+% definition depends on erlang_conf.hrl, which will only be included by this
+% module and not installed.
+:- pragma no_inline(library.version/1).
+
 :- pragma foreign_proc("C",
     library.version(Version::out),
     [will_not_call_mercury, promise_pure, will_not_modify_trail],
@@ -192,11 +196,15 @@
         + mercury.runtime.Constants.MR_FULLARCH;
 ").
 
+:- pragma foreign_decl("Erlang", local, "
+-include(""erlang_conf.hrl"").
+").
+
 :- pragma foreign_proc("Erlang",
     library.version(Version::out),
     [will_not_call_mercury, promise_pure, thread_safe],
 "
-    Version = ?MR_VERSION ++ "" configured for "" ++ ?MR_FULLARCH
+    Version = ?MR_VERSION "" configured for "" ?MR_FULLARCH
 ").
 
 %---------------------------------------------------------------------------%
@@ -225,7 +233,6 @@
 mercury_std_library_module("enum").
 mercury_std_library_module("eqvclass").
 mercury_std_library_module("erlang_builtin").
-mercury_std_library_module("erlang_conf").
 mercury_std_library_module("erlang_rtti_implementation").
 mercury_std_library_module("exception").
 mercury_std_library_module("float").
--------------------------------------------------------------------------
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