[m-rev.] diff: link shared libs with clang on Mac OS X
Julien Fischer
juliensf at csse.unimelb.edu.au
Fri Aug 26 03:47:03 AEST 2011
Branches: main, 11.07
Fix an XXX related to clang and shared libraries on Mac OS X.
configure.in:
Use clang not gcc on Mac OS X for building shared libraries when using
clang as a C compiler.
Delete support for using flat namespaces with dylibs. This was
only necessary for creating dylibs that would work on Mac OS X 10.2
and before; now it's no longer worth maintaining the code in the
configure script that allowed it.
README.MacOS:
Conform to the above change.
Julien.
Index: README.MacOS
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/README.MacOS,v
retrieving revision 1.19
diff -u -r1.19 README.MacOS
--- README.MacOS 25 Aug 2011 14:16:47 -0000 1.19
+++ README.MacOS 25 Aug 2011 17:40:46 -0000
@@ -85,9 +85,8 @@
-------------------------------------
There may be problems with building Mercury on versions of Mac OS X less than
-10.3. In particular there may be problems with building and using shared
-libraries. On these systems you will need to invoke Mercury's configure
-script with the `--enable-darwin-flat-namespace' option.
+10.3. In particular, building shared libraries with Mercury on these systems
+is not supported.
The version of tar in /usr/bin/tar on some older versions of Mac OS X (e.g.
10.1) doesn't work properly -- it truncates long path names. Make sure you
Index: configure.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.585
diff -u -r1.585 configure.in
--- configure.in 25 Aug 2011 15:39:15 -0000 1.585
+++ configure.in 25 Aug 2011 17:40:47 -0000
@@ -4092,7 +4092,7 @@
#-----------------------------------------------------------------------------#
-AC_MSG_CHECKING(whether Mercury supports shared libraries on this system)
+AC_MSG_CHECKING([whether Mercury supports shared libraries on this system])
# We ought to use $target here rather than $host - but we don't
# support cross-compilation at the moment anyhow.
@@ -4378,42 +4378,19 @@
DEFAULT_LINKAGE=static
;;
*apple*darwin*)
- # If the compiler is gcc then use darwin style dynamic linking.
- # Otherwise use static linking.
- # XXX CLANG
- 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,
- AC_HELP_STRING([--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 "
- EXT_FOR_SHARED_LIB=dylib
- EXT_FOR_LINK_WITH_PIC_OBJECTS=o
- CFLAGS_FOR_PIC="-fPIC -DMR_PIC"
- ERROR_UNDEFINED="-undefined error"
- # 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
+ # If the compiler is gcc or clang then use Darwin style dynamic
+ # linking. Otherwise use static linking.
+ case "$C_COMPILER_TYPE" in
+ gcc*|clang*)
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.
+ SHLIB_USE_INSTALL_NAME="--shlib-linker-use-install-name"
+ SHLIB_INSTALL_NAME_FLAG="-install_name "
+ EXT_FOR_SHARED_LIB=dylib
+ EXT_FOR_LINK_WITH_PIC_OBJECTS=o
+ CFLAGS_FOR_PIC="-fPIC -DMR_PIC"
+ ERROR_UNDEFINED="-undefined error"
+ # The MACOSX_DEPLOYMENT_TARGET environment variable needs to be
+ # set so we can use the `-undefined dynamic_lookup' option.
#
# On 10.6, the deployment target needs to be at least 10.4.
# For earlier versions of Mac OS X we use 10.3.
@@ -4431,26 +4408,21 @@
MACOSX_DEPLOYMENT_TARGET=$DEPLOYMENT_TARGET; \
export MACOSX_DEPLOYMENT_TARGET"
AC_SUBST(SET_MACOSX_DEPLOYMENT_TARGET)
- LINK_SHARED_OBJ="$GCC_PROG -multiply_defined suppress \
+ LINK_SHARED_OBJ="$CC -multiply_defined suppress \
-dynamiclib -single_module"
- LINK_SHARED_OBJ_SH="$GCC_PROG -multiply_defined \
+ LINK_SHARED_OBJ_SH="$CC -multiply_defined \
suppress -dynamiclib -single_module"
ALLOW_UNDEFINED="-undefined dynamic_lookup"
- else
+ ;;
+
+ *)
+ CFLAGS_FOR_PIC=
+ EXT_FOR_PIC_OBJECTS=o
+ EXT_FOR_LINK_WITH_PIC_OBJECTS=o
+ DEFAULT_LINKAGE=static
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
- EXT_FOR_LINK_WITH_PIC_OBJECTS=o
- DEFAULT_LINKAGE=static
- AC_MSG_RESULT(no)
- fi
+ ;;
+ esac
;;
arm*-linux|arm*-linux-gnu)
AC_MSG_RESULT(yes)
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list