libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix for 'Cygwin List O' Issues' #1: static runtime libs


From: Charles Wilson
Subject: Re: Fix for 'Cygwin List O' Issues' #1: static runtime libs
Date: Mon, 11 Nov 2002 14:48:57 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2

Charles Wilson wrote:

Any comments on this patch -- on its specifics or its general approach?


I've gotten some feedback from mingw and cygwin 'gcc -mno-cygwin' users. Problems. :-( Plus, the existing patch was not sufficient given cygwin's gcc-3 package.

I had been told that the problem with static runtime libs was because because the new more pedantic libtool now complained in tag=C++ about them. That, however, was only part of the problem. In cygwin's gcc-2.95.3-5 package, which I had been using, /usr/lib contained

libgcc.a libstdc++.a libobjc.a libg2c.a

And all of my testing and development was done under that regime, and solved the problem THERE. However, since I got no feedback from anybody using the newer cygwin gcc-3.2-1 package, I went ahead and upgraded my system to that level. And my fancy patch didn't work.

This is because I was given only a partial diagnosis of the gcc-3 on ccygwin problem. In cygwin's gcc-3 package, /usr/lib now contains

libgcc.a     libgcc.la
libstdc++.a  libstdc++.la

libsupc++.a  libsupc++.la

libg2c.a     libg2c.la

The presence of the .la files means that a different code path is taken in libtool; it never hits my fancy new "allow_libtool_libs_with_static_runtimes" code. After trying (and failing) with a number of approaches, I finally solved this problem by doing the following:

(Current behavior): when libtool is parsing its arguments, whenver it sees a "-lfoo", it builds an .la name from it (libfoo.la), prepends the system search dirs, and hunts for the libtool library. If found, then a whole raft of things are done, but if the .la file includes only an "old_library" entry, then eventually something like the following is added to deplibs:

/usr/lib/gcc-lib/i686-pc-cygwin/3.2/../../../libstdc++.a

And NOT "-lstdc++". This means that the "match the deplib to $postdeps $predeps" code doesn't work, because the long pathname above is not a string match for "-lstdc++".

(New behavior) WHEN a libtool library is found during this stage, THEN

   a) IF allow_libtool_libs_with_static_runtimes = yes
   b) AND IF the deplib (-lstdc++) is in $postdeps or $predeps,
   c) THEN
       1) read in the libtool lib
       2) IF only an old_library is specified and no sharedlibs,
       3) THEN pretend we never found the .la file -- which means
            i) reset $lib to point to the .a file
            2) set $found = no (this means "didn't find a .la file")
            3) add $deplib ("-lstdc++") to deplibs and
               newdependency_libs, as would be done if the .la file
               didn't exist.
   d) later on, the allow_libtool_libs_with_static_runtimes stuff,
      described in the previous message, will kick in and the link
      will succeed.

That way, the problem is solved for the affected systems: mingw, cygwin, pw32 can now "withstand" the presence of .la files corresponding to the runtime libs, where only static versions are specified. But, it doesn't affect systems where either 1) allow_libtool_libs_with_static_runtimes=no (which is all of 'em, except cygwin/mingw/pw32) 2) or where the .la files specify both static AND shared versions (e.g. when cygwin finally gets a shared libstdc++)

^^^^ call this "change 1" ^^^^

----------------------------------

This patch also

change 2) cleans up the $predeps $postdeps matching code a bit, relative to the earlier patch

change 3) fixes the stupid specialdeplibs kludge for gcc on cygwin. Instead, we create a new variable "duplicate_compiler_generated_deps" that is "yes" on cygwin/mingw/pw32, and == $duplicate_deps on all other platforms. Use THAT to gate entry into the loop that adds all members of $predeps $postdeps to $specialdeplibs. This was necessary for building shared libs on mingw (cygwin gcc -mno-cygwin); it wasn't just libgcc that needed special treatment, but libmingw32, libmingwex, kernel32, ... So I just came up with a way to allow ALL compiler-generated deps to avoid duplicate-removal.

change 4) consolidate the separate stanzas for cygwin and mingw when building sharedlibs in C++. The existing version for mingw didn't work; there is no real reason not to use the cygwin invocation on mingw, AFAICT. It is possible that at some later time, the mingw people may want to use
  -Wl,--enable-auto-image-base
instead of cygwin's
  -Wl,--image-base=0x10000000
If so, then that difference should be done within the common stanza; everything else can stay identical. (Cygwin can't use auto-image-base, because that tends to cause relocation conflicts, which cygwin1.dll cannot tolerate during fork/exec.)

change 5) in libtool.m4 (_LT_AC_LOCK), remove support for ancient versions of mingw and cygwin. Everything else has changed so much and depends so heavily on modern ld's, that there is no reason to keep support for these > 4yr old variants (-dll, not -shared, make our own "DLLMain()", ... blech. Get rid of it.) This is somewhat related to change #4.

While these changes may seem to be an unrelated grab bag, they are all necessary to address the "static runtime libs" problem on cygwin and mingw. So they should be treated as a group.

---------------------------------------

With this new patch, libtool (CVS 20021111) has no test regressions on cygwin, and can now successfully build sharedlibs using -mno-cygwin, and works under the new cygwin gcc-3 package regime. (I was even able to build cygiwin's setup.exe using it, which Rob had complained about earlier!)

If anyone wants to test this on cygwin (without the hassle of building it yourself), point cygwin's setup.exe to
  http://www.neuro.gatech.edu/users/cwilson/cygutils/testing/
and upgrade to my test releases of
  autoconf-devel
  autoconf
  automake-devel
  automake
  libtool-stable
  libtool-devel
  libltdl3

I will soon build libtool (CVS-20021111, patched as below) on linux, and run the full testsuite there. I'll report back in a followup to this message.

--Chuck

------------------------------------------------------------

2002-11-02  Charles Wilson  <address@hidden>

        * libtool.m4 (_LT_AC_LOCK): remove support for ancient
        versions of mingw and cygwin.
        (AC_LIBTOOL_POSTDEP_PREDEP): new function.
        moved the "find hidden library dependencies" code here
        from AC_LIBTOOL_LANG_CXX_CONFIG.  Attempted to make it
        multi-tag compatible, but currently only CXX calls it.
        (AC_LIBTOOL_LANG_CXX_CONFIG): set
        enable_shared_with_satic_runtimes to 'no' by default
        Set it to 'yes' for cygwin, mingw, pw32. Replace
        "find hidden library dependencies" code with a call
        to the new function AC_LIBTOOL_POSTDEP_PREDEP.
        Consolidate cygwin and mingw/pw32 stanzas.
        (AC_LIBTOOL_LANG_F77_CONFIG): set
        enable_shared_with_static_runtimes to 'no' by default
        (AC_LIBTOOL_CONFIG): add
        enable_shared_with_static_runtimes to the list of variables
        to write into ltmain.sh; include it in the libtool script
        template as allow_libtool_libs_with_static_runtimes.
        (AC_LIBTOOL_PROG_LD_SHLIBS): set
        enable_shared_with_static_runtimes to 'no' by default
        Set it to 'yes' for cygwin, mingw, pw32.
        (AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE): only put cr in regexp
        if the build_os is mingw, not host_os
        
        * ltmain.in (case deplibs_check_method): for all appropriate
        cases, if allow_libtool_libs_with_static_runtimes, then remove
        predeps and postdeps from the list of dependencies that must
        be checked for "dynamicness".  For the "none" case, the
        presence of compiler-generated postdeps and predeps should
        not trigger "inter-library dependencies not supported" error.
        (initial setup after arg processing): on cygwin/mingw, allow
        compiler-generated dependent libs to be duplicated without
        elimination.
        (initial search loop for deplibs): if the deplib in question
        is a libtool lib, then if
        allow_libtool_libs_with_static_runtimes then parse the .la file.
        If the .la file only has an "old_library", add the deplib
        directly to the deplibs list (-lstdc++) and DON'T use the .la
        file; this allows the (case deplibs_check_method) change above
        to take effect.
        * ltmain.in (for pass in $passes loop): remove predeps,
        postdeps, and compiler_lib_search_path from dependency_libs.

Index: libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/libtool.m4,v
retrieving revision 1.274
diff -u -u -r1.274 libtool.m4
--- libtool.m4  3 Nov 2002 17:35:36 -0000       1.274
+++ libtool.m4  11 Nov 2002 08:32:27 -0000
@@ -495,32 +495,6 @@
   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
   AC_CHECK_TOOL(AS, as, false)
   AC_CHECK_TOOL(OBJDUMP, objdump, false)
-
-  # recent cygwin and mingw systems supply a stub DllMain which the user
-  # can override, but on older systems we have to supply one
-  AC_CACHE_CHECK([if libtool should supply DllMain function], 
lt_cv_need_dllmain,
-    [AC_TRY_LINK([],
-      [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*);
-      DllMain (0, 0, 0);],
-      [lt_cv_need_dllmain=no],[lt_cv_need_dllmain=yes])])
-
-  case $host/$CC in
-  *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*)
-    # old mingw systems require "-dll" to link a DLL, while more recent ones
-    # require "-mdll" (and still newer ones would rather have "-shared")
-    SAVE_CFLAGS="$CFLAGS"
-    CFLAGS="$CFLAGS -shared"
-    AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch,
-      [AC_TRY_LINK([],[],[lt_cv_cc_dll_switch=-shared],
-       [
-         CFLAGS="$SAVE_CFLAGS -mdll"
-       AC_TRY_LINK([], [], 
[lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])])])
-    CFLAGS="$SAVE_CFLAGS" ;;
-  *-*-cygwin* | *-*-pw32*)
-    # cygwin systems need to pass --dll to the linker, and not link
-    # crt.o which will require a address@hidden definition.
-    lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;;
-  esac
   ;;
   ])
 esac
@@ -2428,6 +2402,7 @@
 _LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
 _LT_AC_TAGVAR(no_undefined_flag, $1)=
 _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
 
 # Dependencies to place before and after the object being linked:
 _LT_AC_TAGVAR(predep_objects, $1)=
@@ -2646,12 +2621,13 @@
     esac
     ;;
 
-  cygwin* )
+  cygwin* | mingw* | pw32*)
     # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
     # as there is no search path for DLLs.
     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
     _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
     _LT_AC_TAGVAR(always_export_symbols, $1)=no
+    _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 
     if $LD --help 2>&1 | egrep 'auto-import' > /dev/null; then
       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects 
$libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname 
${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
@@ -2661,19 +2637,6 @@
     fi
        ;;
 
-  mingw* | pw32* )
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
-    _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
-    _LT_AC_TAGVAR(always_export_symbols, $1)=no
-
-    if $LD --help 2>&1 | egrep 'auto-import' > /dev/null; then
-      _LT_AC_TAGVAR(archive_cmds, $1)='$CC '$lt_cv_cc_dll_switch' $libobjs 
$deplibs $compiler_flags -o $output_objdir/$soname ${wl}--out-implib,${lib}'
-      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC '$lt_cv_cc_dll_switch' 
$libobjs $deplibs $compiler_flags -o $output_objdir/$soname 
${wl}-retain-symbols-file $wl$export_symbols ${wl}--out-implib,${lib}'
-    else
-      _LT_AC_TAGVAR(ld_shlibs, $1)=no
-    fi
-       ;;
-
   dgux*)
     case $cc_basename in
       ec++)
@@ -3145,9 +3108,46 @@
 AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
 test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
 
-# Figure out "hidden" C++ library dependencies from verbose
-# compiler output whening linking a shared library.
-cat > conftest.$ac_ext <<EOF
+_LT_AC_TAGVAR(GCC, $1)="$GXX"
+_LT_AC_TAGVAR(LD, $1)="$LD"
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+AC_LIBTOOL_POSTDEP_PREDEP($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_DLOPEN_SELF($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_CXX_CONFIG
+
+# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
+# ------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library.  It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
+int a;
+void foo (void) { a = 0; }
+EOF
+],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
 class Foo
 {
 public:
@@ -3156,8 +3156,25 @@
   int a;
 };
 EOF
-
-
+],[$1],[F77],[cat > conftest.$ac_ext <<EOF
+      subroutine foo
+      implicit none
+      integer*4 a
+      a=0
+      return
+      end
+EOF
+],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
+public class foo {
+  private int a;
+  public void bar (void) {
+    a = 0;
+  }
+};
+EOF
+])
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
 if AC_TRY_EVAL(ac_compile); then
   # Parse the compiler output and extract the necessary
   # objects, libraries and library flags.
@@ -3240,7 +3257,7 @@
   # Clean up.
   rm -f a.out a.exe
 else
-  echo "libtool.m4: error: problem compiling C++ test program"
+  echo "libtool.m4: error: problem compiling $1 test program"
 fi
 
 $rm -f confest.$objext
@@ -3249,29 +3266,7 @@
 *" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
 *) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes ;;
 esac
-
-_LT_AC_TAGVAR(GCC, $1)="$GXX"
-_LT_AC_TAGVAR(LD, $1)="$LD"
-
-## CAVEAT EMPTOR:
-## There is no encapsulation within the following macros, do not change
-## the running order or otherwise move them around unless you know exactly
-## what you are doing...
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-AC_LIBTOOL_SYS_LIB_STRIP
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_DLOPEN_SELF($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_CXX_CONFIG
-
+])# AC_LIBTOOL_POSTDEP_PREDEP
 
 # AC_LIBTOOL_LANG_F77_CONFIG
 # ------------------------
@@ -3296,6 +3291,7 @@
 _LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
 _LT_AC_TAGVAR(no_undefined_flag, $1)=
 _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
 
 # Source file extension for f77 test sources.
 ac_ext=f
@@ -3497,6 +3493,7 @@
     _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
     _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
     _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
+    _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
     _LT_AC_TAGVAR(old_archive_cmds, $1) \
     _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
     _LT_AC_TAGVAR(predep_objects, $1) \
@@ -3611,6 +3608,9 @@
 # Whether or not to add -lc for building shared libraries.
 build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
 
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes,
 $1)
+
 # Whether or not to optimize for fast installation.
 fast_install=$enable_fast_install
 
@@ -3988,7 +3988,7 @@
 
 # Handle CRLF in mingw tool chain
 opt_cr=
-case $host_os in
+case $build_os in
 mingw*)
   opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
   ;;
@@ -4558,7 +4558,7 @@
 ],[
   runpath_var=
   _LT_AC_TAGVAR(allow_undefined_flag, $1)=
-
+  _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
   _LT_AC_TAGVAR(archive_cmds, $1)=
   _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=
   _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
@@ -4658,6 +4658,7 @@
       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
       _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
       _LT_AC_TAGVAR(always_export_symbols, $1)=no
+      _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
 
       if $LD --help 2>&1 | egrep 'auto-import' > /dev/null; then
         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs 
$compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 
${wl}--out-implib,$lib'
@@ -4887,6 +4888,7 @@
       # FIXME: Should let the user specify the lib program.
       _LT_AC_TAGVAR(old_archive_cmds, $1)='lib 
/OUT:$oldlib$oldobjs$old_deplibs'
       fix_srcfile_path='`cygpath -w "$srcfile"`'
+      _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
 
     darwin* | rhapsody*)
Index: ltmain.in
===================================================================
RCS file: /cvsroot/libtool/libtool/ltmain.in,v
retrieving revision 1.310
diff -u -u -r1.310 ltmain.in
--- ltmain.in   3 Nov 2002 17:35:36 -0000       1.310
+++ ltmain.in   11 Nov 2002 08:32:43 -0000
@@ -1668,28 +1668,15 @@
     esac
 
     case $host in
-    *cygwin*)
-      # This is a hack, but we run into problems on cygwin.
-      # libgcc.a depends on libcygwin, but gcc puts -lgcc onto
-      # the link line twice: once before the "normal" libs
-      # (-lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32) and
-      # once AFTER those.  However, the "eliminate dup deps"
-      # procedure keeps only the LAST duplicate -- thus
-      # messing up the order, since after dup elimination
-      # -lgcc comes AFTER -lcygwin.  In normal C operation,
-      # you don't notice the problem, because -lgcc isn't
-      # really used.  However, now that C++ libraries are
-      # libtool-able, you DO see the problem.  So, it must
-      # be fixed.  We could always force "--preserve-dup-deps"
-      # but that could lead to other problems.  So, on cygwin,
-      # always preserve dups of -lgcc...but only -lgcc. That
-      # way, the dependency order won't get corrupted.
-      specialdeplibs="-lgcc"
+    *cygwin* | *mingw* | *pw32*)
+      # don't eliminate duplcations in $postdeps and $predeps
+      duplicate_compiler_generated_deps=yes
       ;;
     *)
-      specialdeplibs=
+      duplicate_compiler_generated_deps=$duplicate_deps
       ;;
     esac
+    specialdeplibs=
 
     libs=
     # Find all interdependent deplibs by searching for libraries
@@ -1710,7 +1697,7 @@
       # $postdeps and mark them as special (i.e., whose duplicates are
       # not to be eliminated).
       pre_post_deps=
-      if test "X$duplicate_deps" = "Xyes" ; then
+      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
        for pre_post_dep in $predeps $postdeps; do
          case "$pre_post_deps " in
          *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" 
;;
@@ -1801,6 +1788,41 @@
              test "$linkmode" = lib && newdependency_libs="$deplib 
$newdependency_libs"
            fi
            continue
+         else # deplib is a libtool library
+           # If $allow_libtool_libs_with_static_runtimes && $deplib is a 
stdlib,
+           # We need to do some special things here, and not later.
+           if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+             case " $predeps $postdeps " in
+             *" $deplib "*)
+               if (${SED} -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") 
>/dev/null 2>&1; then
+                 library_names=
+                 old_library=
+                 case $lib in
+                 */* | *\\*) . $lib ;;
+                 *) . ./$lib ;;
+                 esac
+                 for l in $old_library $library_names; do
+                   ll="$l"
+                 done
+                 if test "X$ll" = "X$old_library" ; then # only static version 
available
+                   found=no
+                   ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
+                   test "X$ladir" = "X$lib" && ladir="."
+                   lib=$ladir/$old_library
+                   if test "$linkmode,$pass" = "prog,link"; then
+                     compile_deplibs="$deplib $compile_deplibs"
+                     finalize_deplibs="$deplib $finalize_deplibs"
+                   else
+                     deplibs="$deplib $deplibs"
+                     test "$linkmode" = lib && newdependency_libs="$deplib 
$newdependency_libs"
+                   fi
+                   continue
+                 fi
+               fi
+               ;;
+             *) ;;
+             esac
+           fi
          fi
          ;; # -l
        -L*)
@@ -2549,6 +2571,19 @@
          eval $var=\"$tmp_libs\"
        done # for var
       fi
+      # Last step: remove runtime libs from dependency_libs (they stay in 
deplibs)
+      tmp_libs=
+      for i in $dependency_libs ; do
+       case " $predeps $postdeps $compiler_lib_search_path " in
+       *" $i "*)
+         i=""
+         ;;
+       esac
+       if test -n "$i" ; then
+         tmp_libs="$tmp_libs $i"
+       fi
+      done
+      dependency_libs=$tmp_libs
     done # for pass
     if test "$linkmode" = prog; then
       dlfiles="$newdlfiles"
@@ -2972,22 +3007,32 @@
            for i in $deplibs; do
              name="`expr $i : '-l\(.*\)'`"
              # If $name is empty we are operating on a -L argument.
-             if test "$name" != "" && test "$name" -ne "0"; then
-               libname=`eval \\$echo \"$libname_spec\"`
-               deplib_matches=`eval \\$echo \"$library_names_spec\"`
-               set dummy $deplib_matches
-               deplib_match=$2
-               if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
-                 newdeplibs="$newdeplibs $i"
-               else
-                 droppeddeps=yes
-                 echo
-                 echo "*** Warning: dynamic linker does not accept needed 
library $i."
-                 echo "*** I have the capability to make that library 
automatically link in when"
-                 echo "*** you link to this library.  But I can only do this 
if you have a"
-                 echo "*** shared version of the library, which I believe you 
do not have"
-                 echo "*** because a test_compile did reveal that the linker 
did not use it for"
-                 echo "*** its dynamic dependency list that programs get 
resolved with at runtime."
+              if test "$name" != "" && test "$name" -ne "0"; then
+               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; 
then
+                 case " $predeps $postdeps " in
+                 *" $i "*)
+                   newdeplibs="$newdeplibs $i"
+                   i=""
+                   ;;             
+                 esac 
+               fi
+               if test -n "$i" ; then
+                 libname=`eval \\$echo \"$libname_spec\"`
+                 deplib_matches=`eval \\$echo \"$library_names_spec\"`
+                 set dummy $deplib_matches
+                 deplib_match=$2
+                 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+                   newdeplibs="$newdeplibs $i"
+                 else
+                   droppeddeps=yes
+                   echo
+                   echo "*** Warning: dynamic linker does not accept needed 
library $i."
+                   echo "*** I have the capability to make that library 
automatically link in when"
+                   echo "*** you link to this library.  But I can only do this 
if you have a"
+                   echo "*** shared version of the library, which I believe 
you do not have"
+                   echo "*** because a test_compile did reveal that the linker 
did not use it for"
+                   echo "*** its dynamic dependency list that programs get 
resolved with at runtime."
+                 fi
                fi
              else
                newdeplibs="$newdeplibs $i"
@@ -2998,28 +3043,38 @@
            # the situation: Compile a separate program for each library.
            for i in $deplibs; do
              name="`expr $i : '-l\(.*\)'`"
-            # If $name is empty we are operating on a -L argument.
-             if test "$name" != "" && test "$name" != "0"; then
+             # If $name is empty we are operating on a -L argument.
+              if test "$name" != "" && test "$name" != "0"; then
                $rm conftest
                $LTCC -o conftest conftest.c $i
                # Did it work?
                if test "$?" -eq 0 ; then
                  ldd_output=`ldd conftest`
-                 libname=`eval \\$echo \"$libname_spec\"`
-                 deplib_matches=`eval \\$echo \"$library_names_spec\"`
-                 set dummy $deplib_matches
-                 deplib_match=$2
-                 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
-                   newdeplibs="$newdeplibs $i"
-                 else
-                   droppeddeps=yes
-                   echo
-                   echo "*** Warning: dynamic linker does not accept needed 
library $i."
-                   echo "*** I have the capability to make that library 
automatically link in when"
-                   echo "*** you link to this library.  But I can only do this 
if you have a"
-                   echo "*** shared version of the library, which you do not 
appear to have"
-                   echo "*** because a test_compile did reveal that the linker 
did not use this one"
-                   echo "*** as a dynamic dependency that programs can get 
resolved with at runtime."
+                 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" 
; then
+                   case " $predeps $postdeps " in
+                   *" $i "*)
+                     newdeplibs="$newdeplibs $i"
+                     i=""
+                     ;;             
+                   esac 
+                 fi
+                 if test -n "$i" ; then
+                   libname=`eval \\$echo \"$libname_spec\"`
+                   deplib_matches=`eval \\$echo \"$library_names_spec\"`
+                   set dummy $deplib_matches
+                   deplib_match=$2
+                   if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; 
then
+                     newdeplibs="$newdeplibs $i"
+                   else
+                     droppeddeps=yes
+                     echo
+                     echo "*** Warning: dynamic linker does not accept needed 
library $i."
+                     echo "*** I have the capability to make that library 
automatically link in when"
+                     echo "*** you link to this library.  But I can only do 
this if you have a"
+                     echo "*** shared version of the library, which you do not 
appear to have"
+                     echo "*** because a test_compile did reveal that the 
linker did not use this one"
+                     echo "*** as a dynamic dependency that programs can get 
resolved with at runtime."
+                   fi
                  fi
                else
                  droppeddeps=yes
@@ -3041,11 +3096,20 @@
          for a_deplib in $deplibs; do
            name="`expr $a_deplib : '-l\(.*\)'`"
            # If $name is empty we are operating on a -L argument.
-           if test "$name" != "" && test  "$name" != "0"; then
-             libname=`eval \\$echo \"$libname_spec\"`
-             for i in $lib_search_path $sys_lib_search_path 
$shlib_search_path; do
-                   potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
-                   for potent_lib in $potential_libs; do
+            if test "$name" != "" && test  "$name" != "0"; then
+             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; 
then
+               case " $predeps $postdeps " in
+               *" $a_deplib "*)
+                 newdeplibs="$newdeplibs $a_deplib"
+                 a_deplib=""    
+                 ;;             
+               esac 
+             fi
+             if test -n "$a_deplib" ; then
+               libname=`eval \\$echo \"$libname_spec\"`
+               for i in $lib_search_path $sys_lib_search_path 
$shlib_search_path; do
+                 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+                 for potent_lib in $potential_libs; do
                      # Follow soft links.
                      if ls -lLd "$potent_lib" 2>/dev/null \
                         | grep " -> " >/dev/null; then
@@ -3071,8 +3135,9 @@
                        a_deplib=""
                        break 2
                      fi
-                   done
-             done
+                 done
+               done
+             fi
              if test -n "$a_deplib" ; then
                droppeddeps=yes
                echo
@@ -3101,20 +3166,30 @@
            name="`expr $a_deplib : '-l\(.*\)'`"
            # If $name is empty we are operating on a -L argument.
            if test -n "$name" && test "$name" != "0"; then
-             libname=`eval \\$echo \"$libname_spec\"`
-             for i in $lib_search_path $sys_lib_search_path 
$shlib_search_path; do
-               potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
-               for potent_lib in $potential_libs; do
-                 potlib="$potent_lib" # see symlink-check above in file_magic 
test
-                 if eval echo \"$potent_lib\" 2>/dev/null \
-                     | ${SED} 10q \
-                     | egrep "$match_pattern_regex" > /dev/null; then
-                   newdeplibs="$newdeplibs $a_deplib"
-                   a_deplib=""
-                   break 2
-                 fi
+             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; 
then
+               case " $predeps $postdeps " in
+               *" $a_deplib "*)
+                 newdeplibs="$newdeplibs $a_deplib"
+                 a_deplib=""    
+                 ;;             
+               esac 
+             fi
+             if test -n "$a_deplib" ; then
+               libname=`eval \\$echo \"$libname_spec\"`
+               for i in $lib_search_path $sys_lib_search_path 
$shlib_search_path; do
+                 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+                 for potent_lib in $potential_libs; do
+                   potlib="$potent_lib" # see symlink-check above in 
file_magic test
+                   if eval echo \"$potent_lib\" 2>/dev/null \
+                       | ${SED} 10q \
+                       | egrep "$match_pattern_regex" > /dev/null; then
+                     newdeplibs="$newdeplibs $a_deplib"
+                     a_deplib=""
+                     break 2
+                   fi
+                 done
                done
-             done
+             fi
              if test -n "$a_deplib" ; then
                droppeddeps=yes
                echo
@@ -3138,9 +3213,16 @@
          ;;
        none | unknown | *)
          newdeplibs=""
-         if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
-              -e 's/ -[LR][^ ]*//g' -e 's/[    ]//g' |
-            grep . >/dev/null; then
+         tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
+           -e 's/ -[LR][^ ]*//g'`
+         if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+           for i in $predeps $postdeps ; do
+             # can't use Xsed below, because $i might contain '/'
+             tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e 
"s,$i,,"`
+           done
+         fi
+         if $echo "X $tmp_deplibs" | $Xsed -e 's/[     ]//g' \
+           | grep . >/dev/null; then
            echo
            if test "X$deplibs_check_method" = "Xnone"; then
              echo "*** Warning: inter-library dependencies are not supported 
in this platform."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]