autoconf-patches
[Top][All Lists]
Advanced

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

Re: _AS_DETECT_BETTER_SHELL speedup


From: Ralf Wildenhues
Subject: Re: _AS_DETECT_BETTER_SHELL speedup
Date: Fri, 28 Jan 2005 12:12:51 +0100
User-agent: Mutt/1.4.1i

* Stepan Kasal wrote on Fri, Jan 28, 2005 at 10:16:00AM CET:
> On Thu, Jan 27, 2005 at 09:51:57PM -0800, Paul Eggert wrote:
> > Ralf Wildenhues <address@hidden> writes:
> > > And on windows, for example, every fork not done is good!
> > 
> > Minor efficiencies like this are not sufficient justification,
> 
> indeed, the speedup is not minor for Windows ports.
> For example, on Cygwin, each fork can take ages.
> 
> > if there is a real risk of breaking things elsewhere.
> 
> I don't think there is a risk of actually _breaking_ the configure
> script.
> 
> Nothing worse can happen than a few spurious 'not found' messages.

Or whatever messages were supposed to be suppressed.

> > > I do not understand this reasoning.  AFAIK Bourne shells fork with
> > > redirected { }, newer shells don't.
> 
> So I propose the following:
> Ralf volunteered to produce a complete patch; let him do it.
> Let's apply the patch; if a problem with unexpected 'not found' messages
> appears, let's revert that patch.

Here it is.  I hope to have been conservative enough:
- left the subshells in the `unset' tests as unsetting an unset variable
  might be erroneous.  Same with (emulate sh), (set -o posix) and the
    ( (MAIL=60; unset MAIL) || exit)
  construct in the m4sh setup, although I believe the first two would be
  safe to do in the current shell.
- hopefully skipped all files that Autoconf is not primary source of
  (the config.guess changes alone are worth it; also Automake will
  receive a similar patch if this one is accepted).
- testsuite passes on a modern system.

Thank you for consideration,
Ralf

        * Makefile.maint, config/mdate-sh, lib/Autom4te/General.pm,
        lib/autoconf/fortran.m4, lib/autoconf/general.m4, lib/autoconf/lang.m4,
        lib/autoconf/libs.m4, lib/autoconf/programs.m4,
        lib/autoconf/specific.m4, lib/autoconf/status.m4,
        lib/autotest/general.m4, lib/m4sugar/m4sh.m4, tests/local.at,
        tests/mktests.sh: Replace all redirected subshells
        ( cmd ) > ... with { cmd; } > ..., whereever cmd has no side-effects
        on the current shell.  Note that now cmd might be run within the
        current shell or within a subshell.

Index: Makefile.maint
===================================================================
RCS file: /cvsroot/autoconf/autoconf/Makefile.maint,v
retrieving revision 1.28
diff -u -r1.28 Makefile.maint
--- Makefile.maint      20 Aug 2004 23:47:48 -0000      1.28
+++ Makefile.maint      28 Jan 2005 09:56:55 -0000
@@ -112,7 +112,7 @@
            exit 1; } || :
 
 sc_space_tab:
-       @( cvsu --list ) > /dev/null 2>&1 || : &&                       \
+       @{ cvsu --list; } > /dev/null 2>&1 || : &&                      \
          grep '[ ]     '                                               \
             $$(cvsu --list | grep -vEf .x-$@ ) &&                      \
          { echo '$(ME): found SPACE-TAB sequence; remove the SPACE'    \
@@ -170,14 +170,14 @@
 # Get list of candidates with this:
 # grep -h include src/sys*.h|sed 's/.*include //'|sort -
 sc_system_h_headers:
-       @( cvsu --list ) > /dev/null 2>&1 || : &&                       \
+       @{ cvsu --list; } > /dev/null 2>&1 || : &&                      \
        grep -E '^# *include ["<]($(h_re))\.h[">]'                      \
            $$(cvsu --list src | grep -Ev 'sys(2|tem)\.h$$')            \
          && { echo '$(ME): the above are already included via system.h'\
                1>&2; exit 1; } || :
 
 sc_sun_os_names:
-       @( cvsu --list ) > /dev/null 2>&1 || : && \
+       @{ cvsu --list; } > /dev/null 2>&1 || : && \
        grep -Ei \
            'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
          $$(cvsu --list | grep -vEf .x-$@ ) &&                 \
Index: lib/Autom4te/General.pm
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/Autom4te/General.pm,v
retrieving revision 1.33
diff -u -r1.33 General.pm
--- lib/Autom4te/General.pm     12 Aug 2004 17:24:16 -0000      1.33
+++ lib/Autom4te/General.pm     28 Jan 2005 09:56:55 -0000
@@ -311,8 +311,8 @@
   my $TMPDIR = $ENV{'TMPDIR'} || '/tmp';
 
   # If mktemp supports dirs, use it.
-  $tmp = `(umask 077 &&
-          mktemp -d -q "$TMPDIR/${signature}XXXXXX") 2>/dev/null`;
+  $tmp = `{ umask 077 &&
+          mktemp -d -q "$TMPDIR/${signature}XXXXXX"; } 2>/dev/null`;
   chomp $tmp;
 
   if (!$tmp || ! -d $tmp)
Index: lib/autoconf/fortran.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/fortran.m4,v
retrieving revision 1.183
diff -u -r1.183 fortran.m4
--- lib/autoconf/fortran.m4     28 Mar 2004 20:46:38 -0000      1.183
+++ lib/autoconf/fortran.m4     28 Jan 2005 09:56:55 -0000
@@ -691,7 +691,7 @@
 # We only consider "LD_RUN_PATH" on Solaris systems.  If this is seen,
 # then we insist that the "run path" must be an absolute path (i.e. it
 # must begin with a "/").
-case `(uname -sr) 2>/dev/null` in
+case `{ uname -sr; } 2>/dev/null` in
    "SunOS 5"*)
       ac_ld_run_path=`echo $ac_[]_AC_LANG_ABBREV[]_v_output |
                         sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'`
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.840
diff -u -r1.840 general.m4
--- lib/autoconf/general.m4     5 Jan 2005 07:53:52 -0000       1.840
+++ lib/autoconf/general.m4     28 Jan 2005 09:56:55 -0000
@@ -388,7 +388,7 @@
 # Name of the host.
 # hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
 # so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+ac_hostname=`{ hostname || uname -n; } 2>/dev/null | sed 1q`
 
 exec AS_MESSAGE_FD>&1
 
Index: lib/autoconf/lang.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/lang.m4,v
retrieving revision 1.169
diff -u -r1.169 lang.m4
--- lib/autoconf/lang.m4        20 Apr 2004 20:15:57 -0000      1.169
+++ lib/autoconf/lang.m4        28 Jan 2005 09:56:55 -0000
@@ -622,7 +622,7 @@
 [AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
 rm -f conftest.o conftest.obj
 AS_IF([AC_TRY_EVAL(ac_compile)],
-[for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+[for ac_file in `{ ls conftest.o conftest.obj; ls conftest.*; } 2>/dev/null`; 
do
   case $ac_file in
     _AC_COMPILER_OBJEXT_REJECT ) ;;
     *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
Index: lib/autoconf/libs.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/libs.m4,v
retrieving revision 1.10
diff -u -r1.10 libs.m4
--- lib/autoconf/libs.m4        5 Sep 2004 03:29:58 -0000       1.10
+++ lib/autoconf/libs.m4        28 Jan 2005 09:56:55 -0000
@@ -188,7 +188,7 @@
 acfindx:
        @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; 
ac_im_libdir="${LIBDIR}"'
 _ACEOF
-  if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
+  if { xmkmf; } >/dev/null 2>/dev/null && test -f Makefile; then
     # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
     eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
     # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
@@ -385,7 +385,7 @@
 dnl FIXME: banish uname from this macro!
     # For Solaris; some versions of Sun CC require a space after -R and
     # others require no space.  Words are not sufficient . . . .
-    case `(uname -sr) 2>/dev/null` in
+    case `{ uname -sr; } 2>/dev/null` in
     "SunOS 5"*)
       AC_MSG_CHECKING([whether -R must be followed by a space])
       ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
Index: lib/autoconf/programs.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/programs.m4,v
retrieving revision 1.38
diff -u -r1.38 programs.m4
--- lib/autoconf/programs.m4    4 Jan 2005 23:50:01 -0000       1.38
+++ lib/autoconf/programs.m4    28 Jan 2005 09:56:55 -0000
@@ -364,7 +364,7 @@
 AC_DEFUN([AC_PROG_EGREP],
 [AC_REQUIRE([AC_PROG_GREP])dnl
 AC_CACHE_CHECK([for egrep], ac_cv_path_EGREP,
-   [if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1
+   [if echo a | { $GREP -E '(a|b)'; } >/dev/null 2>&1
    then ac_cv_path_EGREP="$GREP -E"
    else
      _AC_PROG_GREP(EGREP, egrep, ['EGREP$'])
@@ -379,7 +379,7 @@
 AC_DEFUN([AC_PROG_FGREP],
 [AC_REQUIRE([AC_PROG_GREP])dnl
 AC_CACHE_CHECK([for fgrep], ac_cv_path_FGREP,
-   [if echo 'ab*c' | ($GREP -F 'ab*c') >/dev/null 2>&1
+   [if echo 'ab*c' | { $GREP -F 'ab*c'; } >/dev/null 2>&1
    then ac_cv_path_FGREP="$GREP -F"
    else
      _AC_PROG_GREP(FGREP, fgrep, [FGREP])
Index: lib/autoconf/specific.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/specific.m4,v
retrieving revision 1.360
diff -u -r1.360 specific.m4
--- lib/autoconf/specific.m4    3 May 2004 20:15:44 -0000       1.360
+++ lib/autoconf/specific.m4    28 Jan 2005 09:56:55 -0000
@@ -227,8 +227,8 @@
   (umask 077 && mkdir $ac_xdir 2>/dev/null) || continue
   ac_tf1=$ac_xdir/conftest9012345
   ac_tf2=$ac_xdir/conftest9012346
-  (echo 1 >$ac_tf1) 2>/dev/null
-  (echo 2 >$ac_tf2) 2>/dev/null
+  { echo 1 >$ac_tf1; } 2>/dev/null
+  { echo 2 >$ac_tf2; } 2>/dev/null
   ac_val=`cat $ac_tf1 2>/dev/null`
   if test ! -f $ac_tf1 || test "$ac_val" != 1; then
     ac_cv_sys_long_file_names=no
Index: lib/autoconf/status.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/status.m4,v
retrieving revision 1.48
diff -u -r1.48 status.m4
--- lib/autoconf/status.m4      21 Dec 2004 14:24:01 -0000      1.48
+++ lib/autoconf/status.m4      28 Jan 2005 09:56:55 -0000
@@ -1317,7 +1317,7 @@
   $ $[0] address@hidden
 
 _CSEOF
-echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&AS_MESSAGE_LOG_FD
+echo "on `{ hostname || uname -n; } 2>/dev/null | sed 1q`" >&AS_MESSAGE_LOG_FD
 echo >&AS_MESSAGE_LOG_FD
 _ACEOF
 
Index: lib/autotest/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autotest/general.m4,v
retrieving revision 1.169
diff -u -r1.169 general.m4
--- lib/autotest/general.m4     1 Jan 2005 08:12:12 -0000       1.169
+++ lib/autotest/general.m4     28 Jan 2005 09:56:55 -0000
@@ -170,10 +170,10 @@
   done
 fi
 
-# Not all shells have the 'times' builtin; the subshell is needed to make
+# Not all shells have the 'times' builtin; the { } grouping is needed to make
 # sure we discard the 'times: not found' message from the shell.
 at_times_p=false
-(times) >/dev/null 2>&1 && at_times_p=:
+{ times; } >/dev/null 2>&1 && at_times_p=:
 
 # CLI Arguments to pass to the debugging scripts.
 at_debug_args=
@@ -547,7 +547,7 @@
 } >&AS_MESSAGE_LOG_FD
 
 at_start_date=`date`
-at_start_time=`(date +%s) 2>/dev/null`
+at_start_time=`{ date +%s; } 2>/dev/null`
 echo "$as_me: starting at: $at_start_date" >&AS_MESSAGE_LOG_FD
 at_xpass_list=
 at_xfail_list=
@@ -726,13 +726,13 @@
 
 # Compute the duration of the suite.
 at_stop_date=`date`
-at_stop_time=`(date +%s) 2>/dev/null`
+at_stop_time=`{ date +%s; } 2>/dev/null`
 echo "$as_me: ending at: $at_stop_date" >&AS_MESSAGE_LOG_FD
-at_duration_s=`(expr $at_stop_time - $at_start_time) 2>/dev/null`
-at_duration_m=`(expr $at_duration_s / 60) 2>/dev/null`
-at_duration_h=`(expr $at_duration_m / 60) 2>/dev/null`
-at_duration_s=`(expr $at_duration_s % 60) 2>/dev/null`
-at_duration_m=`(expr $at_duration_m % 60) 2>/dev/null`
+at_duration_s=`{ expr $at_stop_time - $at_start_time; } 2>/dev/null`
+at_duration_m=`{ expr $at_duration_s / 60; } 2>/dev/null`
+at_duration_h=`{ expr $at_duration_m / 60; } 2>/dev/null`
+at_duration_s=`{ expr $at_duration_s % 60; } 2>/dev/null`
+at_duration_m=`{ expr $at_duration_m % 60; } 2>/dev/null`
 at_duration="${at_duration_h}h ${at_duration_m}m ${at_duration_s}s"
 if test "$at_duration" != "h m s"; then
   echo "$as_me: test suite duration: $at_duration" >&AS_MESSAGE_LOG_FD
Index: lib/m4sugar/m4sh.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.131
diff -u -r1.131 m4sh.m4
--- lib/m4sugar/m4sh.m4 3 Jan 2005 23:32:35 -0000       1.131
+++ lib/m4sugar/m4sh.m4 28 Jan 2005 09:56:55 -0000
@@ -234,7 +234,7 @@
 
       for as_shell in $as_candidate_shells $SHELL; do
         AS_IF([_AS_RUN([_AS_DETECT_REQUIRED_BODY],
-                        [($as_shell) 2> /dev/null])],
+                        [{ $as_shell; } 2> /dev/null])],
               [CONFIG_SHELL=$as_shell
               as_have_required=yes
               AS_IF([_AS_RUN([_AS_DETECT_SUGGESTED_BODY], [$as_shell 2> 
/dev/null])],
@@ -619,7 +619,7 @@
          s/.*/./; q']])
 
 m4_defun([AS_DIRNAME],
-[(dirname $1) 2>/dev/null ||
+[{ dirname $1; } 2>/dev/null ||
 AS_DIRNAME_EXPR([$1]) 2>/dev/null ||
 AS_DIRNAME_SED([$1])])
 
@@ -663,7 +663,7 @@
 # --------------------
 # Avoid Solaris 9 /usr/ucb/basename, as `basename /' outputs an empty line.
 m4_defun([_AS_BASENAME_PREPARE],
-[if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+[if { basename /; } >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
   as_basename=basename
 else
   as_basename=false
@@ -694,7 +694,7 @@
 [
   as_lineno_1=$LINENO
   as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+  as_lineno_3=`{ expr $as_lineno_1 + 1; } 2>/dev/null`
   test "x$as_lineno_1" != "x$as_lineno_2" &&
   test "x$as_lineno_3"  = "x$as_lineno_2"])
 
@@ -973,22 +973,22 @@
 cat <<_ASUNAME
 m4_text_box([Platform.])
 
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
-
-/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
-/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
-/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
-/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
-/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+hostname = `{ hostname || uname -n; } 2>/dev/null | sed 1q`
+uname -m = `{ uname -m; } 2>/dev/null || echo unknown`
+uname -r = `{ uname -r; } 2>/dev/null || echo unknown`
+uname -s = `{ uname -s; } 2>/dev/null || echo unknown`
+uname -v = `{ uname -v; } 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `{ /usr/bin/uname -p; } 2>/dev/null || echo unknown`
+/bin/uname -X     = `{ /bin/uname -X; } 2>/dev/null     || echo unknown`
+
+/bin/arch              = `{ /bin/arch; } 2>/dev/null              || echo 
unknown`
+/usr/bin/arch -k       = `{ /usr/bin/arch -k; } 2>/dev/null       || echo 
unknown`
+/usr/convex/getsysinfo = `{ /usr/convex/getsysinfo; } 2>/dev/null || echo 
unknown`
+hostinfo               = `{ hostinfo; } 2>/dev/null               || echo 
unknown`
+/bin/machine           = `{ /bin/machine; } 2>/dev/null           || echo 
unknown`
+/usr/bin/oslevel       = `{ /usr/bin/oslevel; } 2>/dev/null       || echo 
unknown`
+/bin/universe          = `{ /bin/universe; } 2>/dev/null          || echo 
unknown`
 
 _ASUNAME
 
Index: tests/local.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/local.at,v
retrieving revision 1.9
diff -u -r1.9 local.at
--- tests/local.at      1 Jan 2005 08:12:12 -0000       1.9
+++ tests/local.at      28 Jan 2005 09:56:55 -0000
@@ -197,7 +197,7 @@
 # In this case just don't pay attention to the env.  It would be great
 # to keep the error message but we can't: that would break AT_CHECK.
 m4_defun([AC_STATE_SAVE],
-[(set) 2>&1 |
+[{ set; } 2>&1 |
   $GREP -E -v -e 'm4_join([|],
       [^a[cs]_],
       [^((exec_)?prefix|DEFS|CONFIG_STATUS)=],
Index: tests/mktests.sh
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/mktests.sh,v
retrieving revision 1.41
diff -u -r1.41 mktests.sh
--- tests/mktests.sh    3 Jan 2005 07:40:10 -0000       1.41
+++ tests/mktests.sh    28 Jan 2005 09:56:56 -0000
@@ -190,7 +190,7 @@
 
 # egrep
 # -----
-if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+if echo a | { grep -E '(a|b)'; } >/dev/null 2>&1
 then egrep='grep -E'
 else egrep='egrep'
 fi




reply via email to

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