> And how does one duplicate the uname()-dependent choices that can be
> found in the script version? Is it just the AC_DEFINEs in
> configure.in and acconfig.h?
Since no-one provided any hints you've also all but forfeited your
chance to complain about this patch. :-)
It fixes OS X crashes involving Image.JPEG (any possibly other
modules) which is broken due to conflicting library symbols. The patch
preserves the old behavior on 10.2 or older. I've tested on
macosx_ppc32 (10.4), macosx_x86_64 (10.5) and a rhel5_x86_64. Ok to
commit in 7.8?
lipton:7.8 $ cvs diff -u src/configure.in src/acconfig.h src/smartlink.c
bin/smartlink
Index: src/configure.in
===================================================================
RCS file: /pike/data/cvsroot/Pike/7.8/src/configure.in,v
retrieving revision 1.1068
diff -u -r1.1068 configure.in
--- src/configure.in 15 Aug 2008 12:59:51 -0000 1.1068
+++ src/configure.in 19 Aug 2008 09:45:18 -0000
@@ -841,6 +841,22 @@
;;
esac
+# Smartlink needs to know if OS X uses flat or two-level namespace
+if test "$pike_cv_sys_os" = "Darwin" ; then
+ AC_MSG_CHECKING([for Darwin linker namespace])
+ case "`uname -r`" in
+ [1-6].*)
+ AC_MSG_RESULT([flat (10.2 or older)])
+ pike_cv_osx_twolevel_namespace=no
+ ;;
+ *)
+ AC_DEFINE(USE_OSX_TWOLEVEL_NAMESPACE)
+ AC_MSG_RESULT([two-level (10.3 or newer)])
+ pike_cv_osx_twolevel_namespace=yes
+ ;;
+ esac
+fi
+
# Fix a smartlink
SMARTLINK="$BUILDDIR/smartlink"
@@ -7612,7 +7628,16 @@
fi
;;
Darwin*)
- LDSHARED="$REALCC $CFLAGS -bundle -bind_at_load -flat_namespace
-undefined suppress"
+ if test "$pike_cv_osx_twolevel_namespace" = yes ; then
+ # 10.3 or newer take advantage of two-level namespaces to avoid
+ # symbol collisions for e.g. libjpeg which is referenced from both
+ # _Image_JPEG and _Image_TIFF. It requires MACOSX_DEPLOYMENT_TARGET
+ # which is initialized in smartlink to 10.3.
+ LDSHARED="$REALCC $CFLAGS -bundle -bind_at_load -undefined
dynamic_lookup"
+ else
+ # Mac OS X prior to 10.3 need -flat_namespace to support dynamic
modules
+ LDSHARED="$REALCC $CFLAGS -bundle -bind_at_load -flat_namespace
-undefined suppress"
+ fi
;;
IRIX*)
if test "$GCC" = yes ; then
Index: src/acconfig.h
===================================================================
RCS file: /pike/data/cvsroot/Pike/7.8/src/acconfig.h,v
retrieving revision 1.158
diff -u -r1.158 acconfig.h
--- src/acconfig.h 29 Mar 2008 11:50:55 -0000 1.158
+++ src/acconfig.h 19 Aug 2008 09:45:18 -0000
@@ -124,6 +124,9 @@
/* Define this if your ld doesn't have an option to set the run path */
#undef USE_LD_LIBRARY_PATH
+/* Define this on OS X to get two-level namespace support in ld */
+#undef USE_OSX_TWOLEVEL_NAMESPACE
+
/* Define if your tcc supports #pragma TenDRA longlong type allow. */
#undef HAVE_PRAGMA_TENDRA_LONGLONG
Index: src/smartlink.c
===================================================================
RCS file: /pike/data/cvsroot/Pike/7.8/src/smartlink.c,v
retrieving revision 1.20
diff -u -r1.20 smartlink.c
--- src/smartlink.c 18 Aug 2008 14:31:33 -0000 1.20
+++ src/smartlink.c 19 Aug 2008 09:45:18 -0000
@@ -389,6 +389,14 @@
}
}
+#ifdef USE_OSX_TWOLEVEL_NAMESPACE
+ /* Mac OS X needs to be 10.3 or better for ld to accept
+ "-undefined dynamic_lookup" */
+ if (putenv("MACOSX_DEPLOYMENT_TARGET=10.3")) {
+ fatal("Out of memory (8)!\n");
+ }
+#endif
+
execv(argv[1], new_argv);
fprintf(stderr, "%s: exec of %s failed!\n", argv[0], argv[1]);
exit(1);
Index: bin/smartlink
===================================================================
RCS file: /pike/data/cvsroot/Pike/7.8/bin/smartlink,v
retrieving revision 1.30
diff -u -r1.30 smartlink
--- bin/smartlink 9 Mar 2006 20:57:19 -0000 1.30
+++ bin/smartlink 19 Aug 2008 09:45:18 -0000
@@ -192,6 +192,15 @@
# ;;
#esac
+case "$UNAME" in
+ Darwin\ [7-9]*|Darwin\ [1-9][0-9]*)
+ # Needs to be 10.3 or better for ld to accept "-undefined dynamic_lookup"
+ export MACOSX_DEPLOYMENT_TARGET=10.3
+ ;;
+ *)
+ ;;
+esac
+
#echo $LINKER $LDOPTS
# exec $LINKER $LDOPTS