[m-rev.] for review: fix par grade link error on Darwin

Ian MacLarty maclarty at cs.mu.OZ.AU
Tue Dec 21 13:54:59 AEDT 2004


For review by anyone.

Estimated hours taken: 3
Branches: main

Fix build error for hlc.par.gc grade on Darwin.  The problem was that the 
"-undefined suppress" option is not allowed with two level namespaces.
The solution is to use "-undefined dynamic_lookup" instead.
However this means the MACOSX_DEPLOYMENT_TARGET environment variable must be
set to 10.3 since this feature will not work on Mac OS < 10.3.  To allow
hlc.gc.par to be built on Mac 10.3, but targetted for Mac OS 10.0 - 10.2 add 
a configuration option to force the use of flat namespaces (the
"-undefined suppress" option may be used with flat namespaces).

configure.in
	Add --enable-darwin-flat-namespace option.  This is the default
	for Mac OS < 10.3.  For Mac OS 10.3 two level namespaces are used
	unless this option is given.

	Set a variable to cause the MACOSX_DEPLOYMENT_TARGET environment
	variable to be set if two level namespaces are being used.

scripts/mmake.in
scripts/ml.in
scripts/mmc.in
	Set the MACOSX_DEPLOYMENT_TARGET environment variable wherever the
	linker may be called.

Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.409
diff -u -r1.409 configure.in
--- configure.in	15 Dec 2004 06:57:18 -0000	1.409
+++ configure.in	20 Dec 2004 23:29:10 -0000
@@ -2591,8 +2591,7 @@
 [  --enable-libgrades=...
                           install exactly the given versions of the library.
 			  The versions are specified using a comma-separated
-			  list.
-],
+			  list.],
 enable_libgrades_given=yes;enable_libgrades="$enableval",enable_libgrades_given=no)
 
 if test "$enable_most_grades" = no; then
@@ -3227,16 +3226,56 @@
 		# If the compiler is gcc then use darwin style dynamic linking.
 		# Otherwise use static linking.
 		if test "$GCC_PROG" != ""; then
+		    AC_MSG_RESULT(yes)
+		    # Check if the user has explicitly requested that flat
+		    # namespaces be used.
+		    darwin_flat_namespaces=no
+		    AC_ARG_ENABLE(darwin-flat-namespace,
+  			  [  --enable-darwin-flat-namespace  
+			  enable flat namespaces on Darwin.  This is the
+			  default for Darwin versions less than 7 (Mac OS
+			  10.3).  On versions greater than or equal to 7
+			  two-level namespaces are used by default.  This
+			  option therefore only affects Darwin versions 
+			  greater than or equal to 7.],
+		    [ darwin_flat_namespaces=yes ])
 		    SHLIB_USE_INSTALL_NAME="--shlib-linker-use-install-name"
 		    SHLIB_INSTALL_NAME_FLAG="-install_name "
-		    LINK_SHARED_OBJ="$GCC_PROG -dynamiclib -single_module"
-		    LINK_SHARED_OBJ_SH="$GCC_PROG -dynamiclib -single_module"
 		    EXT_FOR_SHARED_LIB=dylib
 		    EXT_FOR_LINK_WITH_PIC_OBJECTS=o
 		    CFLAGS_FOR_PIC="-fPIC -DMR_PIC"
 		    ERROR_UNDEFINED="-undefined error"
-		    ALLOW_UNDEFINED="-undefined suppress"
-		    AC_MSG_RESULT(yes)
+		    # Test if the Darwin version is >= 7.  If it is 
+		    # then we can use the -undefined dynamic_lookup option
+		    # and two-level namespaces.  If it isn't then we use
+		    # flat namespaces.
+		    AC_MSG_CHECKING(whether to use two-level namespaces)
+		    if uname -r | sed "s/^\(@<:@0-9@:>@*\)\..*$/\1/" | \
+		            xargs test "$darwin_flat_namespaces" != "yes" \
+			    -a 7 -le;
+		    then
+		        AC_MSG_RESULT(yes)
+			# The MACOSX_DEPLOYMENT_TARGET environment variable
+			# needs to be set when linking with two level 
+			# namespaces so we can use the
+			# `-undefined dynamic_lookup' option.
+		        SET_MACOSX_DEPLOYMENT_TARGET="\
+				MACOSX_DEPLOYMENT_TARGET=10.3; \
+				export MACOSX_DEPLOYMENT_TARGET"
+			AC_SUBST(SET_MACOSX_DEPLOYMENT_TARGET)
+		        LINK_SHARED_OBJ="$GCC_PROG -multiply_defined suppress \
+				 -dynamiclib -single_module"
+		        LINK_SHARED_OBJ_SH="$GCC_PROG -multiply_defined \ 
+				suppress -dynamiclib -single_module"
+		        ALLOW_UNDEFINED="-undefined dynamic_lookup"
+		    else
+		        AC_MSG_RESULT(no)
+		        LINK_SHARED_OBJ="$GCC_PROG -flat_namespace \
+				-dynamiclib -single_module"
+		        LINK_SHARED_OBJ_SH="$GCC_PROG -flat_namespace \
+				-dynamiclib -single_module"
+		        ALLOW_UNDEFINED="-undefined error"
+		    fi
 		else
 		    CFLAGS_FOR_PIC=
 		    EXT_FOR_PIC_OBJECTS=o
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.112
diff -u -r1.112 ml.in
--- scripts/ml.in	7 Jul 2004 07:11:21 -0000	1.112
+++ scripts/ml.in	20 Dec 2004 23:29:24 -0000
@@ -57,6 +57,10 @@
 # since @SHARED_LIBS_SH@ may refer to $MATH_LIB.
 SHARED_LIBS=${MERCURY_SHARED_LIBS="@SHARED_LIBS_SH@"}
 
+# This environment variable needs to be set to 10.3 on Darwin so that the 
+# -undefined dynamic_lookup option can be specified when linking.
+ at SET_MACOSX_DEPLOYMENT_TARGET@
+
 # When compiling in the hlc.gc grade using the Microsoft Visual C
 # compiler, the default maximum stack size of 4Mb is too low for a
 # recursive language.
Index: scripts/mmake.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmake.in,v
retrieving revision 1.44
diff -u -r1.44 mmake.in
--- scripts/mmake.in	27 Sep 2004 07:55:30 -0000	1.44
+++ scripts/mmake.in	20 Dec 2004 23:29:24 -0000
@@ -80,6 +80,10 @@
 MKTEMP=@MKTEMP@
 TMPDIR=${TMPDIR=/tmp}
 
+# This environment variable needs to be set to 10.3 on Darwin so that the 
+# -undefined dynamic_lookup option can be specified when linking.
+ at SET_MACOSX_DEPLOYMENT_TARGET@
+
 MMAKE=$0
 include_makefile=
 verbose=false
Index: scripts/mmc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmc.in,v
retrieving revision 1.36
diff -u -r1.36 mmc.in
--- scripts/mmc.in	6 Aug 2003 12:38:14 -0000	1.36
+++ scripts/mmc.in	20 Dec 2004 23:29:24 -0000
@@ -18,6 +18,10 @@
 MERCURY_CONFIG_DIR=${MERCURY_CONFIG_DIR-${MERCURY_STDLIB_DIR-'@CONFIG_LIBDIR@'}}
 export MERCURY_COMPILER MERCURY_CONFIG_DIR
 
+# This environment variable needs to be set to 10.3 on Darwin so that the 
+# -undefined dynamic_lookup option can be specified when linking.
+ at SET_MACOSX_DEPLOYMENT_TARGET@
+
 case $# in
 	0) exec $MERCURY_COMPILER ;;
 	*) exec $MERCURY_COMPILER "$@" ;;
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list