[m-dev.] for review: fix for linkage mismatch bug

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Sep 3 21:12:43 AEST 1998


On 03-Sep-1998, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> The change looks good.  As long as it bootchecks ok, it should
> be fine to commit.

No such luck, I'm afraid ;-)

I needed to make the following additional changes in order to
get it to bootcheck.  I'll commit this now.

compiler/base_type_info.m:
        Make base_type_infos always exported from the module, never local.
	This is necessary to ensure that the linkage can be
	computed from the data_name.

library/array.m:
library/builtin.m:
library/std_util.m:
        Add `static' to the hand-coded definitions of the base_type_functors
	and base_type_layouts for builtin types.

Index: base_type_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/base_type_info.m,v
retrieving revision 1.18
diff -u -u -r1.18 base_type_info.m
--- base_type_info.m	1998/08/04 02:13:42	1.18
+++ base_type_info.m	1998/09/03 10:04:02
@@ -138,24 +138,26 @@
 base_type_info__construct_base_type_infos([BaseGenInfo | BaseGenInfos],
 		ModuleInfo, [CModule | CModules]) :-
 	BaseGenInfo = base_gen_info(_TypeId, ModuleName, TypeName, TypeArity,
-		Status, Elim, Procs),
+		_Status, Elim, Procs),
 	base_type_info__construct_pred_addrs(Procs, Elim, ModuleInfo, 
 		PredAddrArgs),
 	ArityArg = yes(const(int_const(TypeArity))),
+
+/******
+It would be more efficient if we could make base_type_infos local,
+but linkage/2 in llds_out.m requires that we make them all exported
+if any of them are exported, so that we can compute the linkage
+from the data_name, for use in forward declarations.
 	( 	
-		( Status = exported ; Status = abstract_exported
-		; Status = imported 	% XXX this is an old hack to make it
-					% work for `term__context', which was
-					% once defined in mercury_builtin.m,
-					% but whose base_type_info was
-					% generated in term.m. 
-					% It's probably not needed anymore.
-		)
+		( Status = exported ; Status = abstract_exported )
 	->
 		Exported = yes
 	;
 		Exported = no
 	),
+******/
+	Exported = yes,
+
 	module_info_globals(ModuleInfo, Globals),
 	globals__lookup_bool_option(Globals, type_layout, TypeLayoutOption),
 	(
Index: array.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.47
diff -u -u -r1.47 array.m
--- array.m	1998/08/24 04:45:15	1.47
+++ array.m	1998/09/03 10:15:22
@@ -269,14 +269,14 @@
 
 #ifdef  USE_TYPE_LAYOUT
 
-const struct mercury_data_array__base_type_layout_array_1_struct {
+static const struct mercury_data_array__base_type_layout_array_1_struct {
 	TYPE_LAYOUT_FIELDS
 } mercury_data_array__base_type_layout_array_1 = {
 	make_typelayout_for_all_tags(TYPELAYOUT_CONST_TAG, 
 		mkbody(TYPELAYOUT_ARRAY_VALUE))
 };
 
-const struct mercury_data_array__base_type_functors_array_1_struct {
+static const struct mercury_data_array__base_type_functors_array_1_struct {
 	Integer f1;
 } mercury_data_array__base_type_functors_array_1 = {
 	MR_TYPEFUNCTORS_SPECIAL
Index: builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.4
diff -u -u -r1.4 builtin.m
--- builtin.m	1998/07/25 12:47:13	1.4
+++ builtin.m	1998/09/03 10:17:33
@@ -201,7 +201,7 @@
 
 	/* base_type_layout for `int' */
 
-const struct mercury_data___base_type_layout_int_0_struct {
+static const struct mercury_data___base_type_layout_int_0_struct {
 	TYPE_LAYOUT_FIELDS
 } mercury_data___base_type_layout_int_0 = {
 	make_typelayout_for_all_tags(TYPELAYOUT_CONST_TAG, 
@@ -210,7 +210,7 @@
 
 	/* base_type_layout for `character' */
 
-const struct mercury_data___base_type_layout_character_0_struct {
+static const struct mercury_data___base_type_layout_character_0_struct {
 	TYPE_LAYOUT_FIELDS
 } mercury_data___base_type_layout_character_0 = {
 	make_typelayout_for_all_tags(TYPELAYOUT_CONST_TAG, 
@@ -219,7 +219,7 @@
 
 	/* base_type_layout for `string' */
 
-const struct mercury_data___base_type_layout_string_0_struct {
+static const struct mercury_data___base_type_layout_string_0_struct {
 	TYPE_LAYOUT_FIELDS
 } mercury_data___base_type_layout_string_0 = {
 	make_typelayout_for_all_tags(TYPELAYOUT_CONST_TAG, 
@@ -228,7 +228,7 @@
 
 	/* base_type_layout for `float' */
 
-const struct mercury_data___base_type_layout_float_0_struct {
+static const struct mercury_data___base_type_layout_float_0_struct {
 	TYPE_LAYOUT_FIELDS
 } mercury_data___base_type_layout_float_0 = {
 	make_typelayout_for_all_tags(TYPELAYOUT_CONST_TAG, 
@@ -237,7 +237,7 @@
 
 	/* base_type_layout for `void' */
 
-const struct mercury_data___base_type_layout_void_0_struct {
+static const struct mercury_data___base_type_layout_void_0_struct {
 	TYPE_LAYOUT_FIELDS
 } mercury_data___base_type_layout_void_0 = {
 	make_typelayout_for_all_tags(TYPELAYOUT_CONST_TAG, 
@@ -248,7 +248,7 @@
 
 	/* base_type_functors for `int' */
 
-const struct mercury_data___base_type_functors_int_0_struct {
+static const struct mercury_data___base_type_functors_int_0_struct {
 	Integer f1;
 } mercury_data___base_type_functors_int_0 = {
 	MR_TYPEFUNCTORS_SPECIAL
@@ -256,7 +256,7 @@
 
 	/* base_type_functors for `character' */
 
-const struct mercury_data___base_type_functors_character_0_struct {
+static const struct mercury_data___base_type_functors_character_0_struct {
 	Integer f1;
 } mercury_data___base_type_functors_character_0 = {
 	MR_TYPEFUNCTORS_SPECIAL
@@ -264,7 +264,7 @@
 
 	/* base_type_functors for `string' */
 
-const struct mercury_data___base_type_functors_string_0_struct {
+static const struct mercury_data___base_type_functors_string_0_struct {
 	Integer f1;
 } mercury_data___base_type_functors_string_0 = {
 	MR_TYPEFUNCTORS_SPECIAL
@@ -272,7 +272,7 @@
 
 	/* base_type_functors for `float' */
 
-const struct mercury_data___base_type_functors_float_0_struct {
+static const struct mercury_data___base_type_functors_float_0_struct {
 	Integer f1;
 } mercury_data___base_type_functors_float_0 = {
 	MR_TYPEFUNCTORS_SPECIAL
@@ -280,7 +280,7 @@
 
 	/* base_type_functors for `void' */
 
-const struct mercury_data___base_type_functors_void_0_struct {
+static const struct mercury_data___base_type_functors_void_0_struct {
 	Integer f1;
 } mercury_data___base_type_functors_void_0 = {
 	MR_TYPEFUNCTORS_SPECIAL
@@ -571,14 +571,14 @@
 
 #ifdef  USE_TYPE_LAYOUT
 
-const struct mercury_data_builtin__base_type_layout_c_pointer_0_struct {
+static const struct mercury_data_builtin__base_type_layout_c_pointer_0_struct {
 	TYPE_LAYOUT_FIELDS
 } mercury_data_builtin__base_type_layout_c_pointer_0 = {
 	make_typelayout_for_all_tags(TYPELAYOUT_CONST_TAG, 
 		mkbody(TYPELAYOUT_C_POINTER_VALUE))
 };
 
-const struct
+static const struct
 mercury_data_builtin__base_type_functors_c_pointer_0_struct {
 	Integer f1;
 } mercury_data_builtin__base_type_functors_c_pointer_0 = {
Index: std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.127
diff -u -u -r1.127 std_util.m
--- std_util.m	1998/08/12 06:16:51	1.127
+++ std_util.m	1998/09/03 10:18:58
@@ -1046,20 +1046,20 @@
 
 #ifdef  USE_TYPE_LAYOUT
 
-const struct mercury_data_std_util__base_type_layout_univ_0_struct {
+static const struct mercury_data_std_util__base_type_layout_univ_0_struct {
 	TYPE_LAYOUT_FIELDS
 } mercury_data_std_util__base_type_layout_univ_0 = {
 	make_typelayout_for_all_tags(TYPELAYOUT_CONST_TAG, 
 		mkbody(TYPELAYOUT_UNIV_VALUE))
 };
 
-const struct mercury_data_std_util__base_type_functors_univ_0_struct {
+static const struct mercury_data_std_util__base_type_functors_univ_0_struct {
 	Integer f1;
 } mercury_data_std_util__base_type_functors_univ_0 = {
 	MR_TYPEFUNCTORS_UNIV
 };
 
-const struct mercury_data_std_util__base_type_layout_type_info_0_struct
+static const struct mercury_data_std_util__base_type_layout_type_info_0_struct
 {
 	TYPE_LAYOUT_FIELDS
 } mercury_data_std_util__base_type_layout_type_info_0 = {
@@ -1067,7 +1067,7 @@
 		mkbody(TYPELAYOUT_TYPEINFO_VALUE))
 };
 
-const struct
+static const struct
 mercury_data_std_util__base_type_functors_type_info_0_struct {
 	Integer f1;
 } mercury_data_std_util__base_type_functors_type_info_0 = {

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list