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

Ian MACLARTY maclarty at cs.mu.OZ.AU
Tue Oct 12 12:11:08 AEST 2004


On Tue, Oct 12, 2004 at 01:57:14AM +1000, Julien Fischer wrote:
> 
> On Tue, 12 Oct 2004, Ian MacLarty wrote:
> 
> > On 10 Oct 2004, at 05:08, Julien Fischer wrote:
> >
> > > > 	1. The -undefined_suppress linker option doesn't work with two level
> > > > 		namespaces which is the default on Darwin.  Is the
> > > > 		--allow-undefined ml option used?  If so should shared libs
> > > > 		rather use flat namespaces.  Alternatively the ALLOW_UNDEFINED
> > > > 		configuration variable can be set to "-undefined
> > > > 		dynamic_lookup", but that'll only work for Mac OS >= 10.3.  I
> > > > 		didn't get any undefined symbols when compiling the compiler.
> > > >
> > > At the moment we should probably just support versions >= 10.3.
> > >
> > I guess, but everything seems to work okay without having to use "-undefined
> > dynamic_lookup", so I don't see the need to resort to this 10.3 specific
> > feature.  Currently everything should in theory still work on 10.2 and 10.1.
> >
> It's probably worth mentioning in README.MacOS that this has not been
> tested on 10.2 and 10.1.
> 

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	12 Oct 2004 01:39:02 -0000
@@ -25,6 +25,8 @@
 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
+
+Linking to shared versions of the Mercury libraries works on Mac OS 10.3, but
+hasn't been tested on previous versions of Mac OS X (although they should).


> > > You should probably an XXX somewhere to this log message that this change
> > > is not sufficient to get dynamic linking working on OS X (and consequently
> > > queries in the debugger still won't work).
> > >
> > I've added the following to the log message:
> >
> > This diff only fixes shared libraries on Darwin, not "bundles" which are shared
> > objects that can be loaded dynamically at runtime using the dlopen c function.
> > Therefore the interactive query tool in the debugger still doesn't work on Mac
> > OS X.
> >
> I'd suggest s/fixes/enables/ there - shared libraries weren't broken so
> there is nothing to fix as such.
> 
Okay.

> > > > Added three new compiler options :
> > > >
> > > > --shlib-linker-use-install-name :
> > > > 	A boolean flag to tell the compiler to use the -install_name option
> > > > 	when building shared libraries.  When this flag is set the following
> > > > 	options have no effect: --linker-rpath-flag, --linker-rpath-separator,
> > > > 	--shlib-linker-rpath-flag, --shlib-linker-rpath-separator.
> > > >
> > > > --shlib-linker-install-name-flag :
> > > > 	The flag name to use ("-install_name" for Darwin).
> > > >
> > > > --shlib-linker-install-name-path :
> > > > 	The path where the shared library will eventually end up, excluding the
> > > > 	file name.  The file name is appended to the end before the option
> > > > 	is passed on to the linker.
> > > Do I need to provide these to the compiler or will mmake do it for me?
> > >
> > mmake will do it all for you.
> >
> You might want to add an XXX comment to the log message if shared
> libraries don't work with mmc --make.
> 
They do work with mmc --make.

> > > > Mmake.common.in
> > > > 	Added variables used for install-name on/off switch and flag name.
> > > >
> > > Do you need to make any changes to Mmake.workspace?
> > >
> > I don't know.  tools/lmc seems to work, although it only seems to
> > statically link in the mercury libraries.  --mercury-linkage may not be an
> > option lmc recognises.
> >
> I think it's meant to do that.
> 
Well then I don't think any changes need to be make to Mmake.workspace - do
you agree?

> > > > configure.in
> > > > 	Make shared libs the default when on Darwin and the compiler is gcc.
> > > >
> > > Is there a way that I can use static linking if I really want it?
> > >
> > Yes.  Specify "--mercury-linkage static" to mmc or add
> > "EXTRA_MLFLAGS = --mercury-libs static" to the Mmakefile.
> >
> (See comment below).
> 
> > > > +	*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
> > > > +		;;
> > > >  	*)
> > > As I mentioned above, there really ought to be a way to tell it
> > > use static linking (perhaps an option to configure?).
> > >
> > You can still use static linking as explained above, but shared is just now the
> > default (as it seems to be for other systems that support it).
> >
> I was thinking more in terms of building the compiler, e.g.
> 
> ./configure --link-statically
> 
> but I guess that's relatively unimportant.
> 
I don't see the need to add this now, since this is not a Darwin specific thing. 
Anyway I think there is an environment variable you can set to do this.

> > @@ -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
> If shared libraries on OS X don't yet work with mmc --make
> you might want to mention that.
> 
They do.

> > 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.
> Why has this comment changed?
> 
There were some extra spaces (not sure how they got in there).  Have
removed them.

> >  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.
> >  #
> This isn't mentioned in the log message.
> 
This is an unrelated comment I just reformatted to fit in 79 columns.
--------------------------------------------------------------------------
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