[m-rev.] For review: Shared Mercury libs on Mac OS X

Ian MacLarty maclarty at cs.mu.OZ.AU
Tue Oct 12 01:14:56 AEST 2004


I've also changed the NEWS and README.MacOS files:

NEWS
	Mentioned shared libs working now on Mac OS X.

README.MacOS
	Removed bit about shared libs not working in Mac OS X.

And have made the default value for the --shlib-linker-install-name-path
option the value of INSTALL_MERC_LIB_DIR, so now there's no need to 
specify this option in browser/Mmakefile and library/Mmakefile.  This also
means user shared libraries can be built using just the INSTALL_PREFIX variable
as documented in the user guide.

I've also included the configure.in diff without Ralph's changes deleted.

The options.m diff just shows the bit where I've changed the default value
of the --shlib-linker-install-name-path option.

Ian.

Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.343
diff -u -r1.343 NEWS
--- NEWS	29 Sep 2004 05:37:36 -0000	1.343
+++ NEWS	11 Oct 2004 14:07:02 -0000
@@ -40,6 +40,7 @@
 
 Portability improvements:
 * We have made the implementation compatible with gcc 3.4.
+* Shared libraries now work on Mac OS X.
 
 Changes to the Mercury debugger:
 * Users can now limit the output from stack traces.
@@ -320,7 +321,8 @@
 
 Portability improvements:
 
-* Nothing yet.
+* We have made the implementation compatible with gcc 3.4.
+* Shared libraries now work on Mac OS X.
 
 Changes to the Mercury debugger:
 
Index: README.MacOS
===================================================================
RCS file: /home/mercury1/repository/mercury/README.MacOS,v
retrieving revision 1.6
diff -u -r1.6 README.MacOS
--- README.MacOS	4 Oct 2004 06:45:13 -0000	1.6
+++ README.MacOS	11 Oct 2004 14:07:02 -0000
@@ -25,6 +25,5 @@
 The fast.gc and asm_fast.gc grades are not supported on PowerPC.
 
 The following features are not yet supported on MacOS:
-	- shared libraries
 	- interactive queries in mdb
 	- the `--split-c-files' option to mmc
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.404
diff -u -r1.404 configure.in
--- configure.in	5 Oct 2004 00:46:26 -0000	1.404
+++ configure.in	11 Oct 2004 14:07:02 -0000
@@ -227,14 +227,17 @@
 			--halt-at-warn $link_static_opt conftest \
 			</dev/null >&AC_FD_CC 2>&1 &&
 		test "`./conftest 2>&1 | tr -d '\015'`" = "Hello, world" &&
-		# Test for the --record-term-sizes-as-words option.
-		# Note that we need to set --grade to an LLDS grade
-		# when doing this test because term size profiling
-		# requires an LLDS grade.
+ 		# Test for the --record-term-sizes-as-words option.
+ 		# Note that we need to set --grade to an LLDS grade
+ 		# when doing this test because term size profiling
+ 		# requires an LLDS grade.
+		# This also tests for the --shlib-linker-intall-name-flag
+		# option.
 		$BOOTSTRAP_MC \
 			--grade none.gc \
 			--record-term-sizes-as-words \
 			--output-grade-string \
+			--shlib-linker-install-name-flag "-dummy_flag" \
 			</dev/null >&AC_FD_CC 2>&1
 	then
 		AC_MSG_RESULT(yes)
@@ -2964,6 +2967,10 @@
 EXE_RPATH_SEP=" -Wl,-rpath,"
 SHLIB_RPATH_OPT="-Wl,-rpath,"
 SHLIB_RPATH_SEP=" -Wl,-rpath,"
+
+SHLIB_USE_INSTALL_NAME=""
+SHLIB_INSTALL_NAME_FLAG="-install_name "
+
 CFLAGS_FOR_PIC="-fpic -DMR_PIC"
 EXT_FOR_PIC_OBJECTS=pic_o
 # Object files with extension $EXT_FOR_LINK_WITH_PIC_OBJECTS are used
@@ -3194,6 +3201,28 @@
 		EXT_FOR_LINK_WITH_PIC_OBJECTS=o
 		DEFAULT_LINKAGE=static
 		;;
+	*powerpc*apple*darwin*)
+		# If the compiler is gcc then use darwin style dynamic linking.
+		# Otherwise use static linking.
+		if test "$GCC_PROG" != ""; then
+		    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)
+		else
+		    CFLAGS_FOR_PIC=
+		    EXT_FOR_PIC_OBJECTS=o
+		    EXT_FOR_LINK_WITH_PIC_OBJECTS=o
+		    DEFAULT_LINKAGE=static
+		    AC_MSG_RESULT(no)
+		fi
+		;;
 	*)
 		# CFLAGS_FOR_PIC is used by boehm_gc/Makefile when creating
 		# libgc.a.  If the system doesn't support shared libraries,
@@ -3363,6 +3392,8 @@
 AC_SUBST(EXE_RPATH_SEP)
 AC_SUBST(SHLIB_RPATH_OPT)
 AC_SUBST(SHLIB_RPATH_SEP)
+AC_SUBST(SHLIB_USE_INSTALL_NAME)
+AC_SUBST(SHLIB_INSTALL_NAME_FLAG)
 AC_SUBST(CFLAGS_FOR_PIC)
 AC_SUBST(EXT_FOR_PIC_OBJECTS)
 AC_SUBST(EXT_FOR_LINK_WITH_PIC_OBJECTS)
@@ -3887,6 +3918,9 @@
 	# then don't do a `make clean' before running `make'.
 	rm -f runtime/libmer_rt.so library/libmer_std.so bytecode/libmbi.so
 	rm -f trace/libmer_trace.so browser/libmer_browse.so
+	rm -f runtime/libmer_rt.dylib library/libmer_std.dylib 
+	rm -f boehm_gc/libgc.dylib bytecode/libmbi.dylib
+	rm -f trace/libmer_trace.dylib browser/libmer_browser.dylib
 	;;
 esac],
 [reconfiguring=$reconfiguring]
Index: browser/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/Mmakefile,v
retrieving revision 1.40
diff -u -r1.40 Mmakefile
--- browser/Mmakefile	2 Aug 2004 08:30:01 -0000	1.40
+++ browser/Mmakefile	11 Oct 2004 14:07:03 -0000
@@ -137,6 +137,7 @@
 	exit $$status
 
 lib$(BROWSER_LIB_NAME).so: lib$(MDBCOMP_LIB_NAME).so
+lib$(BROWSER_LIB_NAME).dylib: lib$(MDBCOMP_LIB_NAME).dylib
 lib$(BROWSER_LIB_NAME): lib$(MDBCOMP_LIB_NAME)
 lib$(BROWSER_LIB_NAME).int3s: lib$(MDBCOMP_LIB_NAME).int3s
 lib$(BROWSER_LIB_NAME).ints: lib$(MDBCOMP_LIB_NAME).ints
@@ -204,8 +205,8 @@
 # with the package name prefixed to the file name with a ".", not a "/".
 # So we copy the Java source files to where the Java compiler expects them to be.
 #
-# XXX This is a hack.  We ought to change the Mercury compiler so that it generates
-# the Java files with the right names in the first place.
+# XXX This is a hack.  We ought to change the Mercury compiler so that it
+# generates the Java files with the right names in the first place.
 #
 
 mdb/%.java: mdb.%.java
Index: compiler/options.m
===================================================================
@@ -1270,7 +1273,10 @@
 	shlib_linker_rpath_flag -	string("-Wl,-rpath"),
 	shlib_linker_rpath_separator -	string(" -Wl,-rpath"),
 	linker_allow_undefined_flag -	string(""),
-	linker_error_undefined_flag -	string("-Wl,-no-undefined")
+	linker_error_undefined_flag -	string("-Wl,-no-undefined"),
+	shlib_linker_use_install_name - bool(no),
+	shlib_linker_install_name_flag - string("-install_name "),
+	shlib_linker_install_name_path - string("$(INSTALL_MERC_LIB_DIR)")
 ]).
 option_defaults_2(build_system_option, [
 		% Build System Options
@@ -1939,6 +1945,9 @@
--------------------------------------------------------------------------
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