[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Darwin status
From: |
Peter O'Gorman |
Subject: |
Re: Darwin status |
Date: |
Tue, 07 Dec 2004 08:02:45 +0900 |
User-agent: |
Mozilla Thunderbird 0.9 (Macintosh/20041103) |
Ralf Wildenhues wrote:
Only minor issues (apart from the fact that I can't test the patch
myself):
You can still test the patch, it affects all platforms, and I only tried it
on freebsd-4.8 (with gnu ar) and darwin8.
I know the long variable names are ugly, and long lines are, too.
Still: can we keep indentation, please?
Made var names shorter and indented.
+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
Won't this copy break -dry-run?
Sorry, I had meant to remove this line when I moved the copy below. Thanks
for catching it.
+$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"
Oh, I'll have to put this place in my next $func_basename patch then (on
HEAD).
Yes, I thought I'd better be consistent (for some value of consistency).
The rest looks ok to me (without doing any testing).
Please test.
Could you state how the test fails before patching ltmain.in?
Does the test succeed on other systems, before and after patching
ltmain.in?
The test would likely pass on all systems using gnu ar. It would fail on
systems with a limited ar. Now it should pass on both. If a system uses an
ar which does not allow multiple objects (ok according to SUSv6) to have the
same name, it will fail.
Please show proposed branch-2-0/HEAD patches before integrating,
because many of the variable usages changed ($echo -> $ECHO and so on).
Okay.
Thanks for looking,
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 6 Dec 2004 22:44:50 -0000
@@ -242,6 +242,44 @@ func_infer_tag () {
}
+# func_extract_an_archive dir oldlib
+func_extract_an_archive () {
+ f_ex_an_ar_dir="$1"; shift
+ f_ex_an_ar_oldlib="$1"
+ f_ex_an_ar_lib=`$echo "X$f_ex_an_ar_oldlib" | $Xsed -e 's%^.*/%%'`
+
+ $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
+ $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
+ if ($AR t "$f_ex_an_ar_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 $f_ex_an_ar_oldlib $f_ex_an_ar_dir/$f_ex_an_ar_lib"
+ $run 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 \
+ | $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
"$f_ex_an_ar_dir/$name_to"
+ do
+ name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+ done
+ $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_lib '$name' && $mv
'$name' '$name_to')"
+ $run 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
+ $show "${rm}r $f_ex_an_ar_dir/$f_ex_an_ar_lib"
+ $run eval "${rm}r \$f_ex_an_ar_dir/\$f_ex_an_ar_lib"
+ fi
+}
+
# func_extract_archives gentop oldlib ...
func_extract_archives () {
my_gentop="$1"; shift
@@ -287,7 +325,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 +337,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,45 +351,17 @@ 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`
done
-
func_extract_archives_result="$my_oldobjs"
}
# End of Shell function definitions
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 6 Dec 2004 22:44:50 -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 6 Dec 2004 22:44:50 -0000
@@ -0,0 +1,83 @@
+#! /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
- Darwin status (Modifié par Akim Demaille), Akim Demaille, 2004/12/04
- Re: Darwin status (Modifié par Akim Demaille ), Peter O'Gorman, 2004/12/04
- Re: Darwin status (Modifié par Akim Demaill e), Akim Demaille, 2004/12/04
- Re: Darwin status (Modifié par Akim Demaille ), Peter O'Gorman, 2004/12/04
- Re: Darwin status, Akim Demaille, 2004/12/04
- Re: Darwin status, Peter O'Gorman, 2004/12/04
- Re: Darwin status, Peter O'Gorman, 2004/12/05
- Re: Darwin status, Peter O'Gorman, 2004/12/05
- Re: Darwin status, Ralf Wildenhues, 2004/12/06
- Re: Darwin status,
Peter O'Gorman <=
- Re: Darwin status, Akim Demaille, 2004/12/07