Prior to this patch, inherite_linker_flags from all dependent libraries
would accumulate, in some cases leading to long command lines due to
multiple repetition; think: library composed of many many convenience
archives.

The patch below fixes this, mostly.  There is still the possibility to
get, say, a couple of `-pthread' entries into the link line, say, if one
instance was passed on the command line, and the other was inherited.
That could be fixed, too, but I don't think that's a major concern
(sorting those out would require munging the -ltframework stuff once
more, to not kill options with arguments, and so on).  The issue is
mostly about exceeding line length on systems like w32 (or is it that
`-framework foo' cannot be listed more than once on Darwin?  A cursory
test doesn't indicate it). 

OK to apply?

Cheers,
Ralf

2007-04-11  Ralf Wildenhues  <[EMAIL PROTECTED]>

        * libltdl/config/ltmain.m4sh (func_mode_link): Fix accumulation
        of `inherited_linker_flags' entries from multiple deplibs, by
        adding $new_inherited_linker_flags only once, only in link pass.
        * tests/inherited_flags: Amend test to expose this.
        * NEWS: Adjust: kill one regression, but add note about the
        feature new in 1.9b.
        Report by Jeff Squyres and others.

Index: NEWS
===================================================================
RCS file: /cvsroot/libtool/libtool/NEWS,v
retrieving revision 1.202
diff -u -r1.202 NEWS
--- NEWS        26 Mar 2007 20:18:43 -0000      1.202
+++ NEWS        11 Apr 2007 22:02:20 -0000
@@ -12,12 +12,6 @@
     any more, some setups may fail.  A mechanism to allow the user to
     choose the mode has not been implemented yet.
 
-  - In 1.9b, a new variable inherited_linker_flags has been added to the
-    libtool library files.  This variable takes flags that should be
-    used by dependent libraries and programs, but that do not fit into
-    `dependency_libs' for both clarity and backward-compatibility.
-    Currently, these flags are not uniquified and thus accumulate.
-
 * Important incompatible changes and obsoleted features:
 
   - Removed deprecated APIs from libltdl: lt_dlcaller_register,
@@ -66,6 +60,10 @@
     Both testsuites have been made more useful for testing
     cross-compilers.  The new testsuite exposes many more issues, but
     may also be a little rocky on exotic systems.
+  - In 1.9b, a new variable inherited_linker_flags has been added to the
+    libtool library files.  This variable takes flags that should be
+    used by dependent libraries and programs, but that do not fit into
+    `dependency_libs' for both clarity and backward-compatibility.
 
 * Changes in supported systems or compilers:
 
Index: libltdl/config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.72
diff -u -r1.72 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  10 Apr 2007 19:09:26 -0000      1.72
+++ libltdl/config/ltmain.m4sh  11 Apr 2007 22:02:22 -0000
@@ -3487,12 +3487,6 @@
          done
        fi
        dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ 
$]*\).ltframework% -framework \1%g'`
-       if test "$linkmode,$pass" = "prog,link"; then
-         compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
-         finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
-       else
-         compiler_flags="$compiler_flags $inherited_linker_flags"
-       fi
        if test "$linkmode,$pass" = "lib,link" ||
           test "$linkmode,$pass" = "prog,scan" ||
           { test "$linkmode" != prog && test "$linkmode" != lib; }; then
@@ -4120,6 +4114,14 @@
          fi # link_all_deplibs != no
        fi # linkmode = lib
       done # for deplib in $libs
+      if test "$pass" = link; then
+       if test "$linkmode" = "prog"; then
+         compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
+         finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
+       else
+         compiler_flags="$compiler_flags $new_inherited_linker_flags"
+       fi
+      fi
       dependency_libs="$newdependency_libs"
       if test "$pass" = dlpreopen; then
        # Link the dlpreopened libraries before other libraries
Index: tests/inherited_flags.at
===================================================================
RCS file: /cvsroot/libtool/libtool/tests/inherited_flags.at,v
retrieving revision 1.11
diff -u -r1.11 inherited_flags.at
--- tests/inherited_flags.at    25 Mar 2007 12:12:43 -0000      1.11
+++ tests/inherited_flags.at    11 Apr 2007 22:02:22 -0000
@@ -41,6 +41,11 @@
 int baz() { return 1;}
 ])
 
+AT_DATA([both.c],
+[
+int both() { return 1;}
+])
+
 AT_DATA([main.c],
 [
 int main() { return 0;}
@@ -49,9 +54,11 @@
 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o foo.lo foo.c
 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o bar.lo bar.c
 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o baz.lo baz.c
+$LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o both.lo both.c
 $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c -o main.lo main.c
 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libfoo.la foo.lo -rpath 
/usr/local/lib -no-undefined
 $LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libbar.la bar.lo -rpath 
/usr/local/lib -no-undefined
+$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libboth.la both.lo 
-rpath /usr/local/lib -no-undefined
 
 
 mv libfoo.la libfoo.la.bak
@@ -62,6 +69,10 @@
 sed -e 
's/^inherited_linker_flags.*/inherited_linker_flags=-llt_unlikely_existing_lib/g'
 < libbar.la.bak > libbar.la
 rm libbar.la.bak
 
+mv libboth.la libboth.la.bak
+sed -e 
"s/^inherited_linker_flags.*/inherited_linker_flags='-llt_inlikely_existing_lib 
-llt_unlikely_existing_lib'/g" < libboth.la.bak > libboth.la
+rm libboth.la.bak
+
 AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libbaz.la 
baz.lo -no-undefined -rpath /usr/local/lib ./libfoo.la ./libbar.la],
         [ignore],[stdout],[ignore])
 # We used to grep for
@@ -76,4 +87,18 @@
 AT_CHECK([grep 'lt_[[ui]]nlikely_existing_lib.*lt_[[ui]]nlikely_existing_lib' 
stdout],
         [0],[ignore],[ignore])
 
+# now check for duplicates
+AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libbaz.la 
baz.lo -no-undefined -rpath /usr/local/lib ./libfoo.la ./libbar.la 
./libboth.la],
+        [ignore],[stdout],[ignore])
+AT_CHECK([grep 'lt_inlikely_existing_lib.*lt_inlikely_existing_lib' stdout],
+        [1],[ignore],[ignore])
+AT_CHECK([grep 'lt_unlikely_existing_lib.*lt_unlikely_existing_lib' stdout],
+        [1],[ignore],[ignore])
+AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o main main.lo 
-no-undefined -rpath /usr/local/lib  ./libfoo.la ./libbar.la ./libboth.la],
+       [ignore],[stdout],[ignore])
+AT_CHECK([grep 'lt_inlikely_existing_lib.*lt_inlikely_existing_lib' stdout],
+        [1],[ignore],[ignore])
+AT_CHECK([grep 'lt_unlikely_existing_lib.*lt_unlikely_existing_lib' stdout],
+        [1],[ignore],[ignore])
+
 AT_CLEANUP


Reply via email to