libtool-patches
[Top][All Lists]
Advanced

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

Re: Bug#348558: libtool: No such file or directory when linking 2 .la fi


From: Ralf Wildenhues
Subject: Re: Bug#348558: libtool: No such file or directory when linking 2 .la files with the same name but from different directories
Date: Sat, 21 Jan 2006 09:25:05 +0100
User-agent: Mutt/1.5.9i

[ this is http://bugs.debian.org/348558 ]

* Carlo Contavalli wrote on Wed, Jan 18, 2006 at 05:01:29PM CET:
> On Wed, Jan 18, 2006 at 03:52:33PM +0100, Ralf Wildenhues wrote:
> 
> > Try the patch at the end (not yet tested very much); it should not be
> > system-specific.
> ok. just applied and tried a compilation. seems to work correctly.

Thanks.

libtool developers: OK to apply this patch and backport to branch-1-5?
Changes wrt. previous proposed patch in above thread: use lt1-libfoo.a
instead of libfoo.a-1 naming, for the dubious benefit of 8+3 filename
systems.  And tests.

Long-winded explanation:
Carlo would like to add two convenience archives with the same name to a
library or a program.  This currently fails on both CVS branches (in
slightly different ways), but IMHO it does not have to, since we can
disambiguate convenience archives by path (unlike real libraries!).  The
patch below fixes this and adds tests to make sure it stays fixed.

Similarly, right now it is not possible to dlpreload two modules with
the same name; in addition to the bugfix below that would also need a
way to disambiguate the prefix for the symbol names.  I actually believe
this can be done in principle (with a bit of help from the user side)
but will leave that for another patch to attack.

The last part of the test uses reloadable objects.  We do not have any
test exposure for these yet -- which means, likely the test needs
adjusting for some systems.

Cheers,
Ralf

        * libltdl/config/ltmain.m4sh (extracted_archives)
        (extracted_serial): New globals.
        (func_extract_archives): Use them to rename extraction archives
        for linking against multiple convenience libraries with the same
        name.
        * tests/duplicate_conv.at: New tests.
        * Makefile.am, tests/testsuite.at: Adjusted.
        Reported by Carlo Contavalli <address@hidden>.

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 07:50:42 -0000
@@ -116,6 +116,8 @@
 preserve_args=
 lo2o="s/\\.lo\$/.${objext}/"
 o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
 
 opt_dry_run=false
 opt_duplicate_deps=false
@@ -1051,7 +1053,17 @@
       esac
       func_basename "$my_xlib"
       my_xlib="$func_basename_result"
-      my_xdir="$my_gentop/$my_xlib"
+      my_xlib_u=$my_xlib
+      while :; do
+        case " $extracted_archives " in
+       *" $my_xlib_u "*)
+         extracted_serial=`expr $extracted_serial + 1`
+         my_xlib_u=lt$extracted_serial-$my_xlib ;;
+       *) break ;;
+      esac
+      done
+      extracted_archives="$extracted_archives $my_xlib_u"
+      my_xdir="$my_gentop/$my_xlib_u"
 
       func_mkdir_p "$my_xdir"
 
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 07:50:41 -0000
@@ -383,6 +383,7 @@
 TESTSUITE_AT   = tests/testsuite.at \
                  tests/am-subdir.at \
                  tests/duplicate_members.at \
+                 tests/duplicate_conv.at \
                  tests/inherited_flags.at \
                  tests/libtoolize.at \
                  tests/nonrecursive.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 07:50:42 -0000
@@ -278,6 +278,7 @@
 m4_include([libtoolize.at])
 # Testing func_extract_archives
 m4_include([duplicate_members.at])
+m4_include([duplicate_conv.at])
 # Test that inherited_linker_flags in the .la actually gets used.
 m4_include([inherited_flags.at])
 # convenience archives test
--- /dev/null   1970-01-01 12:00:00.000000000 +0200
+++ tests/duplicate_conv.at     2006-01-21 07:46:51.000000000 +0100
@@ -0,0 +1,80 @@
+# 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([duplicate convenience archive names])
+
+# We create two convenience archives with the same name, and _also_
+# containing an object with the same name.  This is necessary to detect
+# the failure with both 1.5.22 and HEAD, since the latter does not (did
+# not?) remove the temporary output directory, thus masking the failure
+# when all objects have distinct names.
+
+mkdir a b c
+
+echo 'int a () { return 0; }' > a/a.c
+echo 'int a2() { return 0; }' > b/a.c
+echo 'int b () { return 0; }' > b/b.c
+echo 'extern int a(), a2(), b(); int c() { return a() + a2() + b(); }' > c.c
+echo 'extern int c(); int main() { return c(); }' > main.c
+
+$LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c a/a.c -o a/a.lo
+$LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c b/a.c -o b/a.lo
+$LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c b/b.c -o b/b.lo
+$LIBTOOL --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS -c c.c
+$CC $CPPFLAGS $CFLAGS -c main.c
+$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o a/liba.la a/a.lo
+$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o b/liba.la b/a.lo b/b.lo
+
+# Fold into convenience archive.
+AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libcee.la c.lo 
a/liba.la b/liba.la],
+        [0], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT 
./libcee.la],
+        [0], [ignore], [ignore])
+LT_AT_EXEC_CHECK([./main],[0],[ignore],[ignore])
+$LIBTOOL --mode=clean rm -f libcee.la
+
+
+# FIXME: For this test, we may want to zero out whole_archive_flag_spec;
+#        OTOH, we'd like to test the other situation, too.
+
+# Fold into static library.
+AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -rpath /foo 
-static -o libcee.la c.lo a/liba.la b/liba.la],
+        [0], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT 
./libcee.la],
+        [0], [ignore], [ignore])
+LT_AT_EXEC_CHECK([./main],[0],[ignore],[ignore])
+$LIBTOOL --mode=clean rm -f libcee.la
+
+# Fold into library.
+AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -rpath /foo -o 
libcee.la c.lo a/liba.la b/liba.la],
+        [0], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT 
./libcee.la],
+        [0], [ignore], [ignore])
+LT_AT_EXEC_CHECK([./main],[0],[ignore],[ignore])
+$LIBTOOL --mode=clean rm -f libcee.la
+
+# Test whether this works with reloadable objects as well.
+AT_CHECK([$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o cee.$OBJEXT 
c.lo a/liba.la b/liba.la],
+        [0], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main main.$OBJEXT 
cee.$OBJEXT],
+        [0], [ignore], [ignore])
+LT_AT_EXEC_CHECK([./main],[0],[ignore],[ignore])
+
+# TODO: test dlpreloading of duplicates (when it is implemented)
+
+AT_CLEANUP




reply via email to

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