optimize lt_combine

2008-05-14 Thread Eric Blake
Revisiting an old thread:
http://lists.gnu.org/archive/html/libtool-patches/2007-10/msg00016.html

Here's an optimization to lt_combine, as well as its current clients to match 
the slight semantic changes.  If we ever start requiring autoconf 2.62, we can 
then s/lt_combine/m4_combine/ without impact.  I've updated the patch with the 
conceptual m4sugar improvements that have been made in the meantime, while 
still avoiding m4sugar constructs that were not available prior to 2.62.

Some statistics:

pre-patch:
$ rm -Rf autom4te.cache
$ autoconf --trace lt_combine | wc
  3   31715
$ time autoconf --trace m4_shift | wc
  23859  289406 20200516

real1m18.914s
user1m16.929s
sys 0m1.168s
$ wc autom4te.cache/traces.0 
   81870  1123343 23163745 autom4te.cache/traces.0


post-patch:
$ rm -Rf autom4te.cache
$ time autoconf --trace m4_shift | wc
  20974  281283 16654686

real1m3.968s
user1m2.462s
sys 0m1.288s
$ wc autom4te.cache/traces.0 
   79178   948394 19087599 autom4te.cache/traces.0

Tracing m4_shift is inherently slow (mostly I/O time in generating the trace 
file), since it is used so heavily ;)  But these numbers show that autoconf 
expands roughly 3000 fewer m4_shift calls (not to mention other macros that 
weren't traced), and shaves off more than 4 megabytes of parsing with m4 1.4.x 
(it is not until m4 1.6 that shift is optimized to avoid reparsing everything), 
just by optimizing the three lt_combine calls that occur during libtool's 
configure.ac (not to mention the subdirectories that also run autoconf during 
bootstrap time).

The patch was previously deferred because 2.2 was so close to release; now 
that it is out, is this okay to apply?

From 9bdee069949f55656d0c8bf47914ea809e498592 Mon Sep 17 00:00:00 2001
From: Eric Blake [EMAIL PROTECTED]
Date: Wed, 16 Apr 2008 14:48:47 -0600
Subject: [PATCH] Speed up bootstrap by improving lt_combine.

* libltdl/m4/ltsugar.m4 (lt_combine): Mirror Autoconf 2.62
improvements.  Includes a semantic change where the separator can
now be empty, and where an empty fourth argument is now treated as
a valid suffix.
* libltdl/m4/libtool.m4 (_lt_decl_varnames_tagged): Adjust to new
semantics of lt_combine.
(lt_decl_varnames_tagged): Fix quoting and optimize.

Signed-off-by: Eric Blake [EMAIL PROTECTED]
---
 ChangeLog |   11 +++
 libltdl/m4/libtool.m4 |   12 ++--
 libltdl/m4/ltsugar.m4 |   22 +++---
 3 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e556e7c..58ebb19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-05-14  Eric Blake  [EMAIL PROTECTED]
+
+   Speed up bootstrap by improving lt_combine.
+   * libltdl/m4/ltsugar.m4 (lt_combine): Mirror Autoconf 2.62
+   improvements.  Includes a semantic change where the separator can
+   now be empty, and where an empty fourth argument is now treated as
+   a valid suffix.
+   * libltdl/m4/libtool.m4 (_lt_decl_varnames_tagged): Adjust to new
+   semantics of lt_combine.
+   (lt_decl_varnames_tagged): Fix quoting and optimize.
+
 2008-05-13  Eric Blake  [EMAIL PROTECTED]
 
Kill _LT_LIBSOURCES; it wasn't checking anything useful.
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 4d31e80..1144395 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -380,12 +380,12 @@ m4_define([lt_decl_dquote_varnames],
 # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
 # ---
 m4_define([lt_decl_varnames_tagged],
-[_$0(m4_quote(m4_default([$1], [[, ]])),
- m4_quote(m4_if([$2], [],
-m4_quote(lt_decl_tag_varnames),
- m4_quote(m4_shift($@,
- m4_split(m4_normalize(m4_quote(_LT_TAGS])
-m4_define([_lt_decl_varnames_tagged], [lt_combine([$1], [$2], [_], $3)])
+[m4_assert([$# = 2])dnl
+_$0(m4_quote(m4_default([$1], [[, ]])),
+m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
+m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
+m4_define([_lt_decl_varnames_tagged],
+[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
 
 
 # lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
diff --git a/libltdl/m4/ltsugar.m4 b/libltdl/m4/ltsugar.m4
index 0d258e0..3e576d5 100644
--- a/libltdl/m4/ltsugar.m4
+++ b/libltdl/m4/ltsugar.m4
@@ -1,13 +1,13 @@
 # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
 #
-#   Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
-#   Written by Gary V. Vaughan, 2004
+# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
 #
 # This file is free software; the Free Software Foundation gives
 # unlimited permission to copy and/or distribute it, with or without
 # modifications, as long as this notice is preserved.
 
-# serial 5 ltsugar.m4
+# serial 6 ltsugar.m4
 
 # This is to help aclocal find these macros, as it can't see 

[PATCH] [mingw] Add cross-compile support to cwrapper

2008-05-14 Thread Charles Wilson
[mingw] Add cross-compile support to cwrapper

* libltdl/config/ltmain.m4sh (func_to_host_path):
If present, use winepath to convert from $build to $host
if $host is mingw and $build is neither mingw (msys) nor
cygwin. Also update comments.
(func_to_host_pathlist): Ditto.
---
This is a follow-on to the recent patch dealing with the cwrapper
for mingw and cygwin. This patch adds the ability for cross-compile
setups (where $host=mingw and $build=not mingw/msys, not cygwin, 
but some *nix with wine) to generate correct binary wrappers.

winepath, if found, is used to convert $build (unix) paths to
the appropriate windows-style paths /inside/ the wine environment.
If winepath is not found, then the $build path will be used by
the cwrapper (which is the current behavior for cross-compile to
mingw $host).  Obviously, the $build path is not correct, so the
cwrapper won't work -- but the build will continue successfully
after printing a warning, so no harm.

However, I can't test this patch directly.  The concepts work in 
my stripped-down wine-on-linux install, but I don't have a full
mingw environment to test the whole thing in.  I *did* verify that
this patch causes no regressions for native cygwin, and native mingw.

Also, I think that, even in the best of cases and everything works
as I expect, you'll either have have the linux binfmt extension
working to actually run the test suite in a cross-compile setup, 
because I don't know how you'd convince the testsuite machinery
to prefix every program invocation with '/path/to/wine ...'

Anyway; please /test/.

Chuck


 libltdl/config/ltmain.m4sh |   97 +--
 1 files changed, 65 insertions(+), 32 deletions(-)

diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 0bfae76..197920c 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -2515,12 +2515,19 @@ func_emit_wrapper ()
 #
 # Convert paths to build format when used with build tools.
 # Intended for use with native mingw (where libtool itself
-# is running under the msys shell). Ordinarily, the (msys) shell
-# automatically converts such things for non-msys applications
-# it launches, but that isn't available from inside the cwrapper.
-# Similar accommodations are necessary for $host mingw and $build
-# cygwin.  Calling this function does no harm on other $build or
-# for other $host.
+# is running under the msys shell), or in the following cross-
+# build environments:
+#$build  $host
+#mingw (msys)mingw  [e.g. native]
+#cygwin  mingw
+#*nix + wine mingw
+# where wine is equipped with the `winepath' executable.
+# In the native mingw case, the (msys) shell automatically
+# converts paths for any non-msys applications it launches,
+# but that facility isn't available from inside the cwrapper.
+# Similar accommodations are necessary for $host mingw and
+# $build cygwin.  Calling this function does no harm for other
+# $host/$build combinations not listed above.
 #
 # ARG is the path (on $build) that should be converted to
 # the proper representation for $host. The result is stored
@@ -2546,6 +2553,13 @@ func_to_host_path ()
 func_to_host_path_result=`echo $func_to_host_path_tmp1 |\
   $SED -e $lt_sed_naive_backslashify`
 ;;
+  * )
+if winepath -h /dev/null 21 ; then
+  func_to_host_path_tmp1=`winepath -w $1`
+  func_to_host_path_result=`echo $func_to_host_path_tmp1 |\
+$SED -e $lt_sed_naive_backslashify`
+fi
+;;
 esac
 if test -z $func_to_host_path_result ; then
   func_error Could not determine host path corresponding to
@@ -2561,12 +2575,18 @@ func_to_host_path ()
 # func_to_host_pathlist arg
 #
 # Convert pathlists to build format when used with build tools.
-# See func_to_host_path(), above.
+# See func_to_host_path(), above. This function supports the
+# following $build/$host combinations (but does no harm for
+# combinations not listed here):
+#$build  $host
+#mingw (msys)mingw  [e.g. native]
+#cygwin  mingw
+#*nix + wine mingw
 #
-# Path separators are also converted from ':' to ';', and if
-# $1 begins or ends with a ':' it is preserved (as ';') on
-# output. This description applies only when $build is mingw
-# (msys) or cygwin, and $host is mingw.
+# Path separators are also converted from $build format to
+# $host format. If ARG begins or ends with a path separator
+# character, it is preserved (but converted to $host format)
+# on output.
 #
 # ARG is a pathlist (on $build) that should be converted to
 # the proper representation on $host. The result is stored
@@ -2578,16 +2598,12 @@ func_to_host_pathlist ()
 case $host in
   *mingw* )
 lt_sed_naive_backslashify='s|*|\\|g;s|/|\\|g;s|\\||g'
-case $build in
-  *mingw* | *cygwin* )
-# Remove leading