bug-libtool
[Top][All Lists]
Advanced

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

Re: Darwin status


From: Peter O'Gorman
Subject: Re: Darwin status
Date: Sun, 05 Dec 2004 23:42:21 +0900
User-agent: Mozilla Thunderbird 0.9 (Macintosh/20041103)

Peter O'Gorman wrote:
Peter O'Gorman wrote:

The problem is that ar on darwin has no N flag, so
I haven't found a way to rename the .o's on extraction.

If it works shared, then do that.


I am currently testing a solution to this....

ar, if it accepts files with the same name at all in the archive (this behavior is not required) is meant to only extract the first named file if it is asked to extract a named file, so I can copy the archive, extract named foo.o ; mv foo.o foo-1.o, delete named foo.o from the archive copy, rinse and repeat.

I'm crossing fingers :)

Okay, this works for me, okay to apply to branch-1-5 and eventually get around to forward porting to 2.0 and HEAD?

Peter
--
Peter O'Gorman - http://www.pogma.com
Index: ChangeLog
2004-12-05  Peter O'Gorman  <address@hidden>

        * ltmain.in (func_extract_archives,func_extract_an_archive): On 
        darwin, uniq can not take teh flags -cd together, thanks to Ralf
        for the fix, also ar does not accept N, so we use the fact that
        ar x libfoo.a foo.o will always extract the first foo.o in the
        archive and we then delete foo.o from the archive, which will also
        delete only the first foo.o, then rinse and repeat.
        * tests/func_extract_archives.test: Test this feature.
        * tests/Makefile.am: Add the test.

from  Ralf Wildenhues <address@hidden>
Index: ltmain.in
===================================================================
RCS file: /cvsroot/libtool/libtool/Attic/ltmain.in,v
retrieving revision 1.334.2.41
diff -u -3 -p -u -r1.334.2.41 ltmain.in
--- ltmain.in 1 Dec 2004 18:00:58 -0000 1.334.2.41
+++ ltmain.in 5 Dec 2004 14:39:05 -0000
@@ -242,6 +242,45 @@ func_infer_tag () {
 }
 
 
+# func_extract_an_archive dir oldlib
+func_extract_an_archive () {
+
+func_extract_an_archive_dir="$1"; shift
+func_extract_an_archive_oldlib="$1"
+func_extract_an_archive_lib=`$echo "X$func_extract_an_archive_oldlib" | $Xsed 
-e 's%^.*/%%'`
+
+cp $func_extract_an_archive_oldlib 
$func_extract_an_archive_dir/$func_extract_an_archive_lib
+$show "(cd $func_extract_an_archive_dir && $AR x 
$func_extract_an_archive_oldlib)"
+$run eval "(cd \$func_extract_an_archive_dir && $AR x 
\$func_extract_an_archive_oldlib)" || exit $?
+if ($AR t "$func_extract_an_archive_oldlib" | sort | sort -uc >/dev/null 
2>&1); then
+  :
+else
+  $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
+  $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
+  $show "cp $func_extract_an_archive_oldlib 
$func_extract_an_archive_dir/$func_extract_an_archive_lib"
+  $run eval "cp \$func_extract_an_archive_oldlib 
\$func_extract_an_archive_dir/\$func_extract_an_archive_lib"
+  $AR t "$func_extract_an_archive_oldlib" | sort | uniq -c | $EGREP -v '^[     
]*1[    ]' | while read -r count name
+  do
+       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 
"$func_extract_an_archive_dir/$name_to"
+         do
+       name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+         done
+         $show "(cd $func_extract_an_archive_dir && $AR x  
$func_extract_an_archive_lib '$name' && $mv '$name' '$name_to')"
+         $run eval "(cd \$func_extract_an_archive_dir && $AR x 
\$func_extract_an_archive_lib '$name' && $mv '$name' '$name_to' && $AR -d 
\$func_extract_an_archive_lib '$name')" || exit $?
+         i=`expr $i + 1`
+       done
+  done
+  $show "${rm}r $func_extract_an_archive_dir/$func_extract_an_archive_lib"
+  $run eval "${rm}r 
\$func_extract_an_archive_dir/\$func_extract_an_archive_lib"
+fi
+}
+
 # func_extract_archives gentop oldlib ...
 func_extract_archives () {
     my_gentop="$1"; shift
@@ -287,7 +326,7 @@ func_extract_archives () {
          cd $my_xdir || exit $?
          darwin_archive=$my_xabs
          darwin_curdir=`pwd`
-         darwin_base_archive=`basename $darwin_archive`
+         darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
          darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP 
Architectures 2>/dev/null`
          if test -n "$darwin_arches"; then 
            darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
@@ -299,10 +338,8 @@ func_extract_archives () {
              # Remove the table of contents from the thin files.
              $AR -d 
"unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 
__.SYMDEF 2>/dev/null || true
              $AR -d 
"unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 
__.SYMDEF\ SORTED 2>/dev/null || true
-             cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-             $AR -xo "${darwin_base_archive}"
-             rm "${darwin_base_archive}"
-             cd "$darwin_curdir"
+             func_extract_an_archive 
"unfat-$$/${darwin_base_archive}-${darwin_arch}" "${darwin_base_archive}"
+             rm 
"unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
            done # $darwin_arches
       ## Okay now we have a bunch of thin objects, gotta fatten them up :)
            darwin_filelist=`find unfat-$$ -type f | xargs basename | sort -u | 
$NL2SP`
@@ -315,40 +352,13 @@ func_extract_archives () {
            rm -rf unfat-$$
            cd "$darwin_orig_dir"
          else
-           cd $darwin_orig_dir
-           (cd $my_xdir && $AR x $my_xabs) || exit $?
+           cd "$darwin_orig_dir"
+               func_extract_an_archive "$my_xdir" "$my_xabs"
          fi # $darwin_arches
        fi # $run
       ;;
       *)
-       # We will extract separately just the conflicting names and we will
-       # no longer touch any unique names. It is faster to leave these
-       # extract automatically by $AR in one run.
-       $show "(cd $my_xdir && $AR x $my_xabs)"
-       $run eval "(cd \$my_xdir && $AR x \$my_xabs)" || exit $?
-       if ($AR t "$my_xabs" | sort | sort -uc >/dev/null 2>&1); then
-         :
-       else
-         $echo "$modename: warning: object name conflicts; renaming object 
files" 1>&2
-         $echo "$modename: warning: to ensure that they will not overwrite" 
1>&2
-         $AR t "$my_xabs" | sort | uniq -cd | while read -r count name
-         do
-           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 "$my_xdir/$name_to"
-             do
-               name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
-             done
-             $show "(cd $my_xdir && $AR xN $i $my_xabs '$name' && $mv '$name' 
'$name_to')"
-             $run eval "(cd \$my_xdir && $AR xN $i \$my_xabs '$name' && $mv 
'$name' '$name_to')" || exit $?
-             i=`expr $i + 1`
-           done
-         done
-       fi
+          func_extract_an_archive "$my_xdir" "$my_xabs"
        ;;
       esac
       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name 
\*.lo -print | $NL2SP`
Index: tests/Makefile.am
===================================================================
RCS file: /cvsroot/libtool/libtool/tests/Makefile.am,v
retrieving revision 1.32.2.1
diff -u -3 -p -u -r1.32.2.1 Makefile.am
--- tests/Makefile.am 31 Jul 2003 20:46:41 -0000 1.32.2.1
+++ tests/Makefile.am 5 Dec 2004 14:39:06 -0000
@@ -45,7 +45,8 @@ COMMON_TESTS = \
        quote.test sh.test suffix.test pdemo-conf.test \
        pdemo-make.test pdemo-exec.test pdemo-inst.test \
        mdemo-conf.test mdemo-make.test mdemo2-conf.test \
-       mdemo2-make.test mdemo2-exec.test
+       mdemo2-make.test mdemo2-exec.test \
+       func_extract_archives.test 
 
 
 if HAVE_CXX
@@ -91,4 +92,4 @@ clean-local:
        -test -f ../mdemo/Makefile && cd ../mdemo && $(MAKE) distclean
        -test -f ../tagdemo/Makefile && cd ../tagdemo && $(MAKE) distclean
        -test -f ../f77demo/Makefile && cd ../f77demo && $(MAKE) distclean
-       rm -rf _inst
+       rm -rf _inst .libs
Index: tests/func_extract_archives.test
===================================================================
RCS file: tests/func_extract_archives.test
diff -N tests/func_extract_archives.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/func_extract_archives.test 5 Dec 2004 14:39:06 -0000
@@ -0,0 +1,80 @@
+#! /bin/sh
+# link.test - check that .lo files aren't made into programs.
+
+# Test script header.
+need_prefix=no
+if test -z "$srcdir"; then
+  srcdir=`echo "$0" | sed 's%/[^/]*$%%'`
+  test "$srcdir" = "$0" && srcdir=.
+  test "${VERBOSE+set}" != "set" && VERBOSE=yes
+fi
+. $srcdir/defs || exit 1
+case $host in 
+*darwin*)
+  makefatdarwin=yes
+  ;;
+  *)
+  makefatdarwin=
+  ;;
+esac
+rm -f foo.o bar.o libfoo.a
+SED=${SED-sed}
+Xsed="$SED -e s/^X//"
+for afile in baz foobar foobaz
+do
+if test -n "$makefatdarwin"; then
+echo "ppc $afile" > $afile.ppc.o
+echo "m68k $afile" > $afile.m68k.o
+echo "i386 $afile" > $afile.i386.o
+lipo -create -output $afile.o -arch ppc $afile.ppc.o -arch m68k $afile.m68k.o 
-arch i386 $afile.i386.o
+rm -f $afile.*.o
+ar -q libfoo.a $afile.o
+rm -f $afile.o
+else
+echo "$afile" > $afile.o
+ar -q libfoo.a $afile.o
+rm -f $afile.o
+fi
+done
+for anum in 1 2 3 4 5 6 7 8 9 10 11 12
+do
+if test -n "$makefatdarwin"; then
+echo "ppc foo $anum" > foo.ppc.o
+echo "m68k foo $anum" > foo.m68k.o
+echo "i386 foo $anum" > foo.i386.o
+`lipo -create -output foo.o -arch ppc foo.ppc.o -arch m68k foo.m68k.o -arch 
i386 foo.i386.o`
+ar -q libfoo.a foo.o
+rm -f foo.o foo.*.o
+echo "ppc bar $anum" > bar.ppc.o
+echo "m68k bar $anum" > bar.m68k.o
+echo "i386 bar $anum" > bar.i386.o
+`lipo -create -output bar.o -arch ppc bar.ppc.o -arch m68k bar.m68k.o -arch 
i386 bar.i386.o`
+ar -q libfoo.a bar.o
+rm -f bar.o bar.*.o
+else
+echo "foo $anum" > foo.o
+echo "bar $anum" > bar.o
+ar -q libfoo.a foo.o bar.o
+fi
+done
+test -d .libs || mkdir .libs
+
+eval "`$SED -n -e '/^# Shell function definitions:'$z'$/,/^# End of Shell 
function definitions'$z'$/p' < $libtool`"
+
+show=echo
+run=
+mkdir=mkdir
+rm="rm -"
+mv=mv
+echo=echo
+AR=${AR-ar}
+func_extract_archives ".libs/libfoo" "libfoo.a"
+set -x
+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

reply via email to

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