bug-gnulib
[Top][All Lists]
Advanced

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

reduce forks during autoconf


From: Eric Blake
Subject: reduce forks during autoconf
Date: Tue, 13 May 2008 21:23:08 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

I noticed the following, as part of investigating why autoconf on m4's tree was 
so slow on cygwin:

$ cd m4
$ autoconf --trace m4_syscmd --trace m4_esyscmd | wc
     72     570    4742

It turns out that my additions last September are the culprit [1, 2].  OK to 
apply this patch, which cuts down the number of syscmd forks from 72 to 2?  
Here's how the autoconf run looks when catching the error:

$ mv lib/error.c{,.bak}
$ autoconf -f
missing lib/error.c
configure.ac:68: error: problem checking LIBSOURCES
m4/gnulib-comp.m4:42: M4_INIT is expanded from...
configure.ac:68: the top level
autom4te: /usr/local/bin/m4 failed with exit status: 1

[1] http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=2770108
[2] http://lists.gnu.org/archive/html/bug-gnulib/2007-09/msg00160.html


>From 9c131dc61a6754165869f003dceca01c8fbb14b6 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Tue, 13 May 2008 15:18:04 -0600
Subject: [PATCH] Reduce number of forks required during autoconf.

* gnulib-tool (func_emit_initmacro_start): Prepare
AC_LIBSOURCES_LIST and AC_LIBSOURCES_DIR.
(func_emit_initmacro_end): Use them here in one syscmd...
(func_emit_initmacro_done) <gl_LIBSOURCES>: ...rather than in one
syscmd per file.
<m4_foreach_w>: Move...
* m4/gnulib-common.m4 (m4_foreach_w): ...here.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog           |    9 +++++++++
 gnulib-tool         |   26 ++++++++++++++++----------
 m4/gnulib-common.m4 |    7 +++++++
 3 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0f71c90..6b62a9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-05-13  Eric Blake  <address@hidden>
 
+       Reduce number of forks required during autoconf.
+       * gnulib-tool (func_emit_initmacro_start): Prepare
+       AC_LIBSOURCES_LIST and AC_LIBSOURCES_DIR.
+       (func_emit_initmacro_end): Use them here in one syscmd...
+       (func_emit_initmacro_done) <gl_LIBSOURCES>: ...rather than in one
+       syscmd per file.
+       <m4_foreach_w>: Move...
+       * m4/gnulib-common.m4 (m4_foreach_w): ...here.
+
        * gnulib-tool: Fix various comment typos.
 
 2008-05-12  Bruno Haible  <address@hidden>
diff --git a/gnulib-tool b/gnulib-tool
index a644717..7447d98 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -2046,6 +2046,8 @@ func_emit_initmacro_start ()
   # We let automake know about the files to be distributed through the
   # EXTRA_lib_SOURCES variable.
   echo "  m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}
_LIBSOURCES]))"
+  echo "  m4_pushdef([AC_LIBSOURCES_LIST])"
+  echo "  m4_pushdef([AC_LIBSOURCES_DIR])"
   echo "  gl_COMMON"
 }
 
@@ -2055,6 +2057,18 @@ func_emit_initmacro_start ()
 func_emit_initmacro_end ()
 {
   macro_prefix_arg="$1"
+  echo "  m4_ifset([AC_LIBSOURCES_LIST], ["
+  echo "    m4_syscmd([test ! -d ]AC_LIBSOURCES_DIR[ ||"
+  echo "      for gl_file in ]AC_LIBSOURCES_LIST[ ; do"
+  echo "        if test ! -r ]AC_LIBSOURCES_DIR[/\$gl_file ; then"
+  echo "          echo \"missing ]AC_LIBSOURCES_DIR[/\$gl_file\" >&2"
+  echo "          exit 1"
+  echo "        fi"
+  echo "      done])m4_if(m4_sysval, [0], [],"
+  echo "      [AC_FATAL([problem checking LIBSOURCES])])"
+  echo "  ])"
+  echo "  m4_popdef([AC_LIBSOURCES_DIR])"
+  echo "  m4_popdef([AC_LIBSOURCES_LIST])"
   echo "  m4_popdef([AC_LIBSOURCES])"
   echo "  m4_popdef([AC_REPLACE_FUNCS])"
   echo "  m4_popdef([AC_LIBOBJ])"
@@ -2090,13 +2104,6 @@ func_emit_initmacro_done ()
   echo "  ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS 
\$1.\$ac_objext\""
   echo "])"
   echo
-  echo "# m4_foreach_w is provided by autoconf-2.59c and later."
-  echo "# This definition is to accommodate developers using versions"
-  echo "# of autoconf older than that."
-  echo "m4_ifndef([m4_foreach_w],"
-  echo "  [m4_define([m4_foreach_w],"
-  echo "    [m4_foreach([\$1], m4_split(m4_normalize([\$2]), [ ]), [\$3])])])"
-  echo
   echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
   echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
   echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
@@ -2111,9 +2118,8 @@ func_emit_initmacro_done ()
   echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
   echo "  m4_foreach([_gl_NAME], [\$1], ["
   echo "    m4_if(_gl_NAME, [alloca.c], [], ["
-  echo "      m4_syscmd([test -r $sourcebase_arg/]_gl_NAME[ || test ! -d 
$sourcebase_arg])dnl"
-  echo "      m4_if(m4_sysval, [0], [],"
-  echo "        [AC_FATAL([missing $sourcebase_arg/]_gl_NAME)])"
+  echo "      m4_define([AC_LIBSOURCES_DIR], [$sourcebase_arg])"
+  echo "      m4_append_uniq([AC_LIBSOURCES_LIST], _gl_NAME, [ ])"
   echo "    ])"
   echo "  ])"
   echo "])"
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 3edfc12..d52af8e 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -31,6 +31,13 @@ AC_DEFUN([gl_MODULE_INDICATOR],
     [Define to 1 when using the gnulib module ]$1[.])
 ])
 
+# m4_foreach_w
+# is a backport of autoconf-2.59c's m4_foreach_w.
+# Remove this macro when we can assume autoconf >= 2.60.
+m4_ifndef([m4_foreach_w],
+  [m4_define([m4_foreach_w],
+    [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
+
 # AC_PROG_MKDIR_P
 # is a backport of autoconf-2.60's AC_PROG_MKDIR_P.
 # Remove this macro when we can assume autoconf >= 2.60.
-- 
1.5.5.1








reply via email to

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