]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
Peter O'Gorman <peter@pogma.com>
authorAlexandre Oliva <aoliva@redhat.com>
Sun, 17 Apr 2005 14:30:34 +0000 (14:30 +0000)
committerPeter O'Gorman <peter@pogma.com>
Sun, 17 Apr 2005 14:30:34 +0000 (14:30 +0000)
* config/ltmain.m4sh: Don't add files with the same base name to an
archive; rename duplicates instead.
(func_extract_an_archive): Remove section to deal with duplicate
base names in an archive.
* tests/functests.at: remove.
* tests/duplicate_members.at: new test.
* tests/testsuite.at: Add new test, remove old.
* Makefile.am: Add new test, remove old.

ChangeLog
Makefile.am
config/ltmain.m4sh
tests/duplicate_members.at [new file with mode: 0755]
tests/functests.at [deleted file]
tests/testsuite.at

index fbe5019d2154c972794272f3206d0f4eec1b8ec5..36aff6fcb5399f29138d549279b1f8d12ea64a5f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-04-17 Alexandre Oliva  <aoliva@redhat.com>,
+          Peter O'Gorman  <peter@pogma.com>
+
+       * config/ltmain.m4sh: Don't add files with the same base name to an 
+       archive; rename duplicates instead.
+       (func_extract_an_archive): Remove section to deal with duplicate
+       base names in an archive.
+       * tests/functests.at: remove.
+       * tests/duplicate_members.at: new test.
+       * tests/testsuite.at: Add new test, remove old.
+       * Makefile.am: Add new test, remove old.
+
 2005-04-17  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * tests/demo-hardcode.test [solaris]:  Use dumpstabs if available,
index ad68eef7386c7157681768212aa41e7f99592822..2041ccb68cf5819caf64d95baf34c0fd9b1d3ed7 100644 (file)
@@ -301,7 +301,7 @@ dist-hook:
 TESTSUITE      = tests/testsuite
 TESTSUITE_AT   = tests/testsuite.at \
                  tests/am-subdir.at \
-                 tests/functests.at \
+                 tests/duplicate_members.at \
                  tests/inherited_flags.at \
                  tests/libtoolize.at \
                  tests/stresstest.at \
index 651101534dd7c70103c7e8093e9c486a9105f0c2..a43a8ac7f74a08894c4f39e55da12280257a55c5 100644 (file)
@@ -987,30 +987,7 @@ func_extract_an_archive ()
     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
      :
     else
-      func_basename "$f_ex_an_ar_oldlib"
-      f_ex_an_ar_lib="$func_basename_result"
-      func_warning "$modename: warning: object name conflicts; renaming object files" 1>&2
-      func_warning "$modename: warning: to ensure that they will not overwrite" 1>&2
-      func_show_eval "cp \$f_ex_an_ar_oldlib \$f_ex_an_ar_dir/\$f_ex_an_ar_lib"
-      $AR t "$f_ex_an_ar_oldlib" | sort | uniq -c | while read count name
-      do
-       # We don't want to do anything to objects with unique names
-        test "$count" -eq 1 && continue
-       i=1
-       while test "$i" -le "$count"
-         do
-         # Put our $i before any first dot (extension)
-         # Never overwrite any file
-         name_to="$name"
-         while test "X$name_to" = "X$name" || test -f "$f_ex_an_ar_dir/$name_to"
-           do
-           name_to=`$ECHO "X$name_to" | $Xsed -e "s/\([[^.]]*\)/\1-$i/"`
-         done
-         func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_lib '$name' && $MV '$name' '$name_to' && $AR d \$f_ex_an_ar_lib '$name')" || exit $?
-         i=`expr $i + 1`
-       done
-      done
-      func_show_eval "$RM \$f_ex_an_ar_dir/\$f_ex_an_ar_lib"
+      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
     fi
 }
 
@@ -6304,6 +6281,50 @@ fi\
          oldobjs="$oldobjs $func_extract_archives_result"
        fi
 
+       # POSIX demands no paths to be encoded in archives.  We have
+       # to avoid creating archives with duplicate basenames if we
+       # might have to extract them afterwards, e.g., when creating a
+       # static archive out of a convenience library, or when linking
+       # the entirety of a libtool archive into another (currently
+       # not supported by libtool).
+       if (for obj in $oldobjs
+           do
+             func_basename "$obj"
+             $ECHO "$func_basename_result"
+           done | sort | sort -uc >/dev/null 2>&1); then
+         :
+       else
+         $ECHO "copying selected object files to avoid basename conflicts..."
+         gentop="$output_objdir/${outputname}x"
+         generated="$generated $gentop"
+         func_mkdir_p "$gentop"
+         save_oldobjs=$oldobjs
+         oldobjs=
+         counter=1
+         for obj in $save_oldobjs
+         do
+           func_basename "$obj"
+           objbase="$func_basename_result"
+           case " $oldobjs " in
+           " ") oldobjs=$obj ;;
+           *[[\ /]]"$objbase "*)
+             while :; do
+               # Make sure we don't pick an alternate name that also
+               # overlaps.
+               newobj=lt$counter-$objbase
+               counter=`expr $counter + 1`
+               case " $oldobjs " in
+               *[[\ /]]"$newobj "*) ;;
+               *) if test ! -f "$gentop/$newobj"; then break; fi ;;
+               esac
+             done
+             func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+             oldobjs="$oldobjs $gentop/$newobj"
+             ;;
+           *) oldobjs="$oldobjs $obj" ;;
+           esac
+         done
+       fi
        eval cmds=\"$old_archive_cmds\"
 
        if len=`expr "X$cmds" : ".*"` &&
@@ -6317,21 +6338,6 @@ fi\
          objlist=
          concat_cmds=
          save_oldobjs=$oldobjs
-         # GNU ar 2.10+ was changed to match POSIX; thus no paths are
-         # encoded into archives.  This makes 'ar r' malfunction in
-         # this piecewise linking case whenever conflicting object
-         # names appear in distinct ar calls; check, warn and compensate.
-           if (for obj in $save_oldobjs
-           do
-             func_basename "$obj"
-             $ECHO "$func_basename_result"
-           done | sort | sort -uc >/dev/null 2>&1); then
-           :
-         else
-           func_warning "object name conflicts; overriding AR_FLAGS to 'cq'"
-           func_warning "to ensure that POSIX-compatible ar will work"
-           AR_FLAGS=cq
-         fi
          # Is there a better way of finding the last object in the list?
          for obj in $save_oldobjs
          do
diff --git a/tests/duplicate_members.at b/tests/duplicate_members.at
new file mode 100755 (executable)
index 0000000..9fb3809
--- /dev/null
@@ -0,0 +1,75 @@
+# Hand crafted tests for GNU Libtool.                         -*- Autotest -*-
+# Copyright 2005 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., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+AT_BANNER([Testing libtool functions])
+AT_SETUP([duplicate members in archive tests])
+
+
+LIBTOOL=${abs_top_builddir}/libtool
+
+# we don't want to use whole_archive_flag_spec, even if available
+sed -e 's|^whole_archive_flag_spec=.*|whole_archive_flag_spec=|g' < $LIBTOOL > libtool
+
+chmod +x ./libtool
+LIBTOOL=./libtool
+
+eval `$LIBTOOL --config | grep ^EGREP=`
+eval `$LIBTOOL --config | $EGREP '(host|build)='`
+
+AT_DATA(bar.c,
+[[int bar() {
+    int result=foo1() +foo2() +foo3() +foo4() +foo5() +foo6();
+    return result;
+}
+]])
+
+AT_DATA(main.c,
+[[int bar();
+int main()
+{
+if (bar() == 21) return 0;
+return 1;
+}
+]])
+
+
+for a in 1 2 3 4 5 6
+do
+  mkdir $a
+  echo "int foo$a() {return $a;}" > $a/a.c
+done
+
+
+for a in 1 2 3 4 5 6
+do
+  $LIBTOOL --mode=compile --tag=CC $CC -c $CFLAGS -o $a/a.lo $a/a.c
+done
+$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libc0.la 6/a.lo
+$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libconv.la 1/a.lo 2/a.lo 3/a.lo 4/a.lo 5/a.lo libc0.la
+
+$LIBTOOL --mode=compile --tag=CC $CC -c $CFLAGS -o bar.lo bar.c
+$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o libbar.la bar.lo libconv.la -rpath /notexist
+
+$LIBTOOL --mode=compile --tag=CC $CC -c $CFLAGS -o main.lo main.c
+$LIBTOOL --mode=link --tag=CC $CC $CFLAGS $LDFLAGS -o main main.lo ./libbar.la
+
+AT_CHECK([./main],[0],[ignore],[ignore],[AT_CHECK(if 
+       ((test "X$host" != "X$build") &&
+       ( test -x ./main)); then exit 77; fi)])
+
+AT_CLEANUP
diff --git a/tests/functests.at b/tests/functests.at
deleted file mode 100644 (file)
index 74993c5..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-# Hand crafted tests for GNU Libtool.                         -*- Autotest -*-
-# Copyright 2004 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., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-
-AT_BANNER([Libtool's shell function tests.])
-
-AT_SETUP([func_extract_archives tests])
-
-sed -n -e '/^# TEST SUITE MARKER ## BEGIN SOURCABLE$/,/^# TEST SUITE MARKER ## NON-FUNCTION$/p' < ${abs_top_builddir}/libtool > ltdefs
-
-AT_DATA(func_extract_archives,
-[[#! /bin/sh
-# func_extract_archives
-. ./ltdefs
-SED=${SED-sed}
-Xsed="$SED -e 1s/^X//"
-progname=libtool
-mode=testing
-
-for afile in baz foobar foobaz
-do
-    echo "$afile" > $afile.o
-    ar -q libfoo.a $afile.o
-    rm -f $afile.o
-done
-
-for anum in 1 2 3 4 5 6 7 8 9 10 11 12
-do
-    echo "foo $anum" > foo.o
-    echo "bar $anum" > bar.o
-    ar -q libfoo.a foo.o bar.o
-done
-test -d .libs || mkdir .libs
-
-func_extract_archives ".libs/libfoo" "libfoo.a"
-for anum in 1 2 3 4 5 6 7 8 9 10 11 12
-do
-  test -f ".libs/libfoo/libfoo.a/foo-$anum.o" || exit 1
-  $EGREP -v "foo-$anum" ".libs/libfoo/libfoo.a/foo-$anum.o" || exit 1
-  rm -f ".libs/libfoo/libfoo.a/foo-$anum.o"
-done
-rm -rf ".libs/libfoo"
-exit 0
-]])
-
-chmod +x func_extract_archives
-
-AT_CHECK([./func_extract_archives],[0],[ignore],[ignore])
-
-AT_CLEANUP
index afebcb8e3758fb0b5b41b2eb949320c3d7a58598..b9dcbdbcb8cdeb0f5e05262f902da40fd145b1e2 100644 (file)
@@ -63,7 +63,7 @@ AT_INIT
 # Torturing subdir-objects builds
 m4_include([am-subdir.at])
 # Testing func_extract_archives
-m4_include([functests.at])
+m4_include([duplicate_members.at])
 # Test that inherited_linker_flags in the .la actually gets used.
 m4_include([inherited_flags.at])
 # stress test