While we're on the subject of darwin and libtool, we've been needing to
make changes to libtool to make KDE compile on darwin that haven't been
discussed in this thread.

Darwin's GCC has a number of very weird states it can get into during
the linking stage because of it's crappy ld (grin), and I don't think
many things have exercised them until we tried to get something really
big to build with libtool.

Attached is a patch with some of the fixes that have gone into the
KDE-Darwin tree.  I haven't done all of these changes myself, Dave
Vasilevsky (who has posted libtool patches previously, I think) is the
one who found most of these issues.

The libtool.m4 bit includes the fixed module test discussed here in the
last couple of days, as well as the -install_name bug, but it also fixes
some symbol issues when linking some C++ bits.  It basically has to
implement a two-pass compile to make linking happy.  The second part
(the ltmain.in bit) disables lazy linking because of C++ issues as well.

The patch is made against libtool CVS top-of-tree as of a few minutes
ago; if you have any problems with it or need changes, let me know.  It
would be great to have darwin linking properly out-of-the-box with
libtool.  =)


Index: libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/libtool.m4,v
retrieving revision 1.265
diff -u -b -r1.265 libtool.m4
--- libtool.m4  4 Oct 2002 15:34:50 -0000       1.265
+++ libtool.m4  8 Oct 2002 22:00:05 -0000
@@ -2631,6 +2631,12 @@
          _LT_AC_TAGVAR(ld_shlibs, $1)=no
         ;;
 
+  darwin*)
+    shared_flag='-dynamiclib'
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o 
+${lib}-master.o $libobjs && $CC -dynamiclib -install_name $rpath/$soname 
+$predep_objects ${lib}-master.o $deplibs $postdep_objects $compiler_flags -o $lib'
+    output_verbose_link_cmd='$CC -dynamiclib $CFLAGS -v conftest.$objext 2>&1 | egrep 
+"\-L"'
+    ;;
+
   dgux*)
     case $cc_basename in
       ec++)
@@ -4950,7 +4956,7 @@
       #        cross-compilation, but unfortunately the echo tests do not
       #        yet detect zsh echo's removal of \ escapes.  Also zsh mangles
       #               `"' quotes if we put them in here... so don't!
-      _LT_AC_TAGVAR(archive_cmds, $1)='$CC $(test .$module = .yes && echo -bundle || 
echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linker_flags 
-install_name $rpath/$soname $verstring'
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o 
+${lib}-master.o $libobjs && $CC $(test .$module = .yes && echo -bundle || echo 
+-dynamiclib) $allow_undefined_flag -o $lib ${lib}-master.o $deplibs$linker_flags 
+$(test .$module != .yes && echo -install_name $rpath/$soname $verstring)'
       # We need to add '_' to the symbols in $export_symbols first
       #_LT_AC_TAGVAR(archive_expsym_cmds, $1)="$_LT_AC_TAGVAR(archive_cmds, $1)"' && 
strip -s $export_symbols'
       _LT_AC_TAGVAR(hardcode_direct, $1)=yes
Index: ltmain.in
===================================================================
RCS file: /cvsroot/libtool/libtool/ltmain.in,v
retrieving revision 1.301
diff -u -b -r1.301 ltmain.in
--- ltmain.in   25 Sep 2002 04:26:20 -0000      1.301
+++ ltmain.in   8 Oct 2002 22:00:06 -0000
@@ -3644,6 +3644,14 @@
        ;;
       esac
 
+      case $host in
+      *darwin*)
+        # Don't allow lazy linking, it breaks C++ global constructors
+        compile_command="$compile_command ${wl}-bind_at_load"
+        finalize_command="$finalize_command ${wl}-bind_at_load"
+        ;;
+      esac
+
       compile_command="$compile_command $compile_deplibs"
       finalize_command="$finalize_command $finalize_deplibs"
 

Reply via email to