libtool-patches
[Top][All Lists]
Advanced

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

Fix linking against uninstalled libs again (1/n)


From: Ralf Wildenhues
Subject: Fix linking against uninstalled libs again (1/n)
Date: Sat, 21 Jan 2006 09:37:27 +0100
User-agent: Mutt/1.5.9i

I messed up pretty badly while trying to fix the "linking against
uninstalled deplibs" right before 1.5.22 -- guess that's what I get
for not testing extensively.  Please accept my apologies.

The changes applied to branch-1-5 had two flaws (at least):
a) They did not move all paths to uninstalled libs up front.
b) They removed some uninstalled libs in some cases.

(Patches below are shown for CVS HEAD, but branch-1-5 is quite similar)


(b) is due to this change, which has actually not yet been applied to
HEAD but to branch-1-5 (the 2005-12-18 patch by Peter and me):

--- libltdl/config/ltmain.m4sh  11 Jan 2006 17:24:56 -0000      1.28
+++ libltdl/config/ltmain.m4sh  21 Jan 2006 00:40:25 -0000
@@ -4480,9 +4495,9 @@
 
       # Eliminate all temporary directories.
       for path in $notinst_path; do
-       lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e 's% $path % %g'`
-       deplibs=`$ECHO "X$deplibs " | $Xsed -e 's% -L$path % %g'`
-       dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e 's% -L$path % 
%g'`
+       lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
+       deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
+       dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % 
%g"`
       done
 
       if test -n "$xrpath"; then

I still need to think about this patch.  Maybe we should drop this,
or only do it for relink.  (Using sed is ugly anyway, as all '.' and
other regex special characters will match too much here, so it would
need a rewrite anyway.)


(a) should be fixed by the patch below.  It contains a hopefully
sufficiently complete set of tests to make sure we don't break this
again.

In order to fix (b), we'll need another set of tests, that will come
later.

OK to apply the patch below (and backport the ltmain diff)?

Cheers,
Ralf

        * libltdl/config/ltmain.m4sh (func_mode_link): Also 
        * tests/uninstalled.at: New tests.
        * Makefile.am, tests/testsuite.at

Index: libltdl/config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.28
diff -u -r1.28 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  11 Jan 2006 17:24:56 -0000      1.28
+++ libltdl/config/ltmain.m4sh  21 Jan 2006 00:32:36 -0000
@@ -3503,12 +3518,12 @@
            dir="$ladir"
            absdir="$abs_ladir"
            # Remove this search path later
-           notinst_path="$notinst_path $abs_ladir"
+           notinst_path="$notinst_path $abs_ladir $dir"
          else
            dir="$ladir/$objdir"
            absdir="$abs_ladir/$objdir"
            # Remove this search path later
-           notinst_path="$notinst_path $abs_ladir"
+           notinst_path="$notinst_path $abs_ladir $dir"
          fi
        fi # $installed = yes
        func_stripname 'lib' '.la' "$laname"
@@ -4887,15 +4902,16 @@
       # installed libraries to the beginning of the library search list
       new_libs=
       for path in $notinst_path; do
-       case " $new_libs " in
-       *" -L$path/$objdir "*) ;;
-       *)
-         case " $deplibs " in
-         *" -L$path/$objdir "*)
-           new_libs="$new_libs -L$path/$objdir" ;;
+       for p in $path $path/$objdir; do
+         case " $new_libs " in
+         *" -L$p "*) ;;
+         *)
+           case " $deplibs " in
+           *" -L$p "*) new_libs="$new_libs -L$p" ;;
+           esac
+           ;;
          esac
-         ;;
-       esac
+       done
       done
       for deplib in $deplibs; do
        case $deplib in
@@ -5504,15 +5520,16 @@
       # installed libraries to the beginning of the library search list
       new_libs=
       for path in $notinst_path; do
-       case " $new_libs " in
-       *" -L$path/$objdir "*) ;;
-       *)
-         case " $compile_deplibs " in
-         *" -L$path/$objdir "*)
-           new_libs="$new_libs -L$path/$objdir" ;;
+       for p in $path $path/$objdir; do
+         case " $new_libs " in
+         *" -L$p "*) ;;
+         *)
+           case " $compile_deplibs " in
+           *" -L$p "*) new_libs="$new_libs -L$p" ;;
+           esac
+           ;;
          esac
-         ;;
-       esac
+       done
       done
       for deplib in $compile_deplibs; do
        case $deplib in
Index: Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/Makefile.am,v
retrieving revision 1.185
diff -u -r1.185 Makefile.am
--- Makefile.am 3 Jan 2006 14:02:19 -0000       1.185
+++ Makefile.am 21 Jan 2006 00:32:34 -0000
@@ -393,6 +394,7 @@
                  tests/stresstest.at \
                  tests/subproject.at \
                  tests/link-order.at \
+                 tests/uninstalled.at \
                  tests/fail.at \
                  tests/convenience.at \
                  tests/early-libtool.at \
Index: tests/testsuite.at
===================================================================
RCS file: /cvsroot/libtool/libtool/tests/testsuite.at,v
retrieving revision 1.35
diff -u -r1.35 testsuite.at
--- tests/testsuite.at  16 Dec 2005 16:15:32 -0000      1.35
+++ tests/testsuite.at  21 Jan 2006 00:32:37 -0000
@@ -278,12 +278,13 @@
 m4_include([libtoolize.at])
 # Testing func_extract_archives
 m4_include([duplicate_members.at])
 # Test that inherited_linker_flags in the .la actually gets used.
 m4_include([inherited_flags.at])
 # convenience archives test
 m4_include([convenience.at])
 # link order test
 m4_include([link-order.at])
+# link against uninstalled libraries
+m4_include([uninstalled.at])
 # ensure failure
 m4_include([fail.at])
 # Ensure our continued support for old interfaces.
--- /dev/null   2005-03-20 10:56:34.000000000 +0100
+++ tests/uninstalled.at        2006-01-20 23:39:59.000000000 +0100
@@ -0,0 +1,104 @@
+# Hand crafted tests for GNU Libtool.                         -*- Autotest -*-
+# Copyright 2006 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+AT_SETUP([linking uninstalled libraries])
+
+LDFLAGS="$LDFLAGS -no-undefined"
+
+libdir=`pwd`/inst
+mkdir a b m $libdir
+
+# Create the old, installed library.
+echo "int a_old () { return 1; }" > a/a.c
+$LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c a/a.c -o a/a.lo
+$LIBTOOL --mode=link --tag=CC $CC $CPPFLAGS $CFLAGS $LDFLAGS \
+        -L $libdir -rpath $libdir -o a/liba.la a/a.lo
+$LIBTOOL --mode=install cp a/liba.la $libdir/liba.la
+$LIBTOOL --mode=clean rm -f a/liba.la
+
+# Create the new library: either link- or execution-time incompatible.
+for old in _old ""; do
+  echo "int a$old() { return 0; }" > a/a.c
+  $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c a/a.c -o a/a.lo
+  cd m
+  echo "extern int a$old(); int main() { return a$old(); }" > main.c
+  $CC $CPPFLAGS $CFLAGS -c main.c
+  cd ..
+
+  for flag_deplib in "" "-L$libdir"; do
+    linkline="$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS $flag_deplib \
+             -rpath $libdir -o a/liba.la a/a.lo"
+    AT_CHECK([echo $linkline; $linkline], [0], [ignore], [ignore])
+
+    cd m
+    for flag_instlib in "" "-L$libdir"; do
+      for deplib_path in ../a `pwd`/../a `cd ../a && pwd`; do
+       linkline="$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $flag_instlib \
+                 -o main main.$OBJEXT $deplib_path/liba.la"
+       AT_CHECK([echo $linkline; $linkline], [0], [ignore], [ignore])
+       LT_AT_EXEC_CHECK([./main])
+       $LIBTOOL --mode=clean rm -f main
+      done
+    done
+    cd ..
+
+    $LIBTOOL --mode=clean rm -f a/liba.la
+  done
+done
+
+# Now the same thing, but while creating a dependent library.
+for old in _old ""; do
+  echo "int a$old() { return 0; }" > a/a.c
+  $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c a/a.c -o a/a.lo
+  echo "extern int a$old(); int b() { return a$old(); }" > b/b.c
+  $LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c b/b.c -o b/b.lo
+
+  for flag_deplib in "" "-L$libdir"; do
+    linkline="$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS $flag_deplib \
+              -rpath $libdir -o a/liba.la a/a.lo"
+    AT_CHECK([echo $linkline; $linkline], [0], [ignore], [ignore])
+
+    for flag_lib in "" "-L$libdir"; do
+      cd b
+      for lib_path in ../a `pwd`/../a  `cd ../a && pwd`; do
+       linkline="$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS $flag_lib \
+                 -rpath $libdir -o libb.la b.lo $lib_path/liba.la"
+       AT_CHECK([echo $linkline; $linkline], [0], [ignore], [ignore])
+
+       cd ../m
+       echo "extern int a$old(), b(); int main() { return a$old() + b(); }" > 
main.c
+       $CC $CPPFLAGS $CFLAGS -c main.c
+       for flag_instlib in "" "-L$libdir"; do
+         linkline="$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS $flag_instlib \
+                   -o main main.$OBJEXT ../b/libb.la"
+         AT_CHECK([echo $linkline; $linkline], [0], [ignore], [ignore])
+         LT_AT_EXEC_CHECK([./main])
+         $LIBTOOL --mode=clean rm -f main
+       done
+       cd ../b
+
+       $LIBTOOL --mode=clean rm -f libb.la
+      done
+      cd ..
+    done
+
+    $LIBTOOL --mode=clean rm -f a/liba.la
+  done
+done
+
+AT_CLEANUP




reply via email to

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