[m-rev.] for review: fix namespace cleanliness check on Mac OS X

Julien Fischer jfischer at opturion.com
Fri Jan 4 17:42:14 AEDT 2013


For review by anyone.

----------------

Make the namespace cleanliness check work on Mac OS X.

Fix an old problem: the check_objs target would fail on Mac OS X because
exported symbols on that platform are prefixed with "_".

Mmmake.common.in:
    Allow object symbols to have an optional system-specific prefix.

    Delete a workaround for a problem that was fixed five years ago.

configure.ac:
    On Darwin systems set the appropriate symbol prefix.

Julien.

diff --git a/Mmake.common.in b/Mmake.common.in
index db79aa8..5fdd170 100644
--- a/Mmake.common.in
+++ b/Mmake.common.in
@@ -322,22 +322,18 @@ OBJ_CHECKS        = $(CHECK_OBJS:%=%.obj_check)
 # XXX The base_typeclass_info prefix is allowed only temporarily; it should
 # be fixed by adding a prefix giving the name of the module defining the
 # typeclass.
-#
-# XXX the pretty_printer_ prefix is allows only tempriarily; it is neccessary
-# because the name of global variables used for mutables in rotd-2007-08-06 and
-# before were not being prefixed with `mercury_' if they were defined in
-# standard library modules.

 GEN_MACRO_PREFIX_EXPRS = \
 	-e '^MR_' -e '^MERCURY_' -e '^GC_' -e '^MPS_' -e '^mps_'
 GEN_OBJ_PREFIX_EXPRS = \
-	-e '^MR_' -e '^_entry' -e '^mercury_'  -e '^base_typeclass_info_' -e
'^pretty_printer_'
+	-e '^@SYMPREFIX at MR_' -e '^_entry' -e '^@SYMPREFIX at mercury_' \
+	-e '^@SYMPREFIX at base_typeclass_info_'

 ifeq ("$(ALLOW_LIB_PREFIX)","yes")
 LIB_MACRO_PREFIX_EXPRS = \
 	-e '^ML_'
 LIB_OBJ_PREFIX_EXPRS = \
-	-e '^ML_'
+	-e '^@SYMPREFIX at ML_'
 else
 LIB_MACRO_PREFIX_EXPRS =
 LIB_OBJ_PREFIX_EXPRS =
@@ -347,7 +343,7 @@ ifeq ("$(ALLOW_BROWSER_PREFIX)","yes")
 BROWSER_MACRO_PREFIX_EXPRS = \
 	-e '^MDB_'
 BROWSER_OBJ_PREFIX_EXPRS = \
-	-e '^MDB_' -e '^mdb_'
+	-e '^@SYMPREFIX at MDB_' -e '^@SYMPREFIX at mdb_'
 else
 BROWSER_MACRO_PREFIX_EXPRS =
 BROWSER_OBJ_PREFIX_EXPRS =
@@ -357,7 +353,7 @@ ifeq ("$(ALLOW_MDBCOMP_PREFIX)","yes")
 MDBCOMP_MACRO_PREFIX_EXPRS = \
 	-e '^MDBCOMP_'
 MDBCOMP_OBJ_PREFIX_EXPRS = \
-	-e '^MDBCOMP_' -e '^mdbcomp_'
+	-e '^@SYMPREFIX at MDBCOMP_' -e '^@SYMPREFIX at mdbcomp_'
 else
 MDBCOMP_MACRO_PREFIX_EXPRS =
 MDBCOMP_OBJ_PREFIX_EXPRS =
@@ -367,7 +363,7 @@ ifeq ("$(ALLOW_SSDB_PREFIX)","yes")
 SSDB_MACRO_PREFIX_EXPRS = \
 	-e '^SSDB_'
 SSDB_OBJ_PREFIX_EXPRS = \
-	-e '^SSDB_' -e '^ssdb_'
+	-e '^@SYMPREFIX at SSDB_' -e '^@SYMPREFIX at ssdb_'
 else
 SSDB_MACRO_PREFIX_EXPRS =
 SSDB_OBJ_PREFIX_EXPRS =
diff --git a/configure.ac b/configure.ac
index 3309b09..0773f84 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3159,6 +3159,19 @@ fi

 #-----------------------------------------------------------------------------#

+# On some systems a prefix is attached to exported symbols.  We need to
+# account for this when check object files for namespace cleanliness.
+
+SYMPREFIX=
+
+case "$host" in
+    *apple*darwin*) SYMPREFIX="_"
+esac
+
+AC_SUBST([SYMPREFIX])
+
+#-----------------------------------------------------------------------------#
+
 #
 # Figure out which is the best grade to use for various different purposes.
 # In particular, choose the default grade for compiling applications.



More information about the reviews mailing list