libtool-patches
[Top][All Lists]
Advanced

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

back out AS_SHELL_SANITIZE: get compile mode up to speed


From: Ralf Wildenhues
Subject: back out AS_SHELL_SANITIZE: get compile mode up to speed
Date: Wed, 17 May 2006 20:53:32 +0200
User-agent: Mutt/1.5.11+cvs20060403

This patch fixes a long-standing compile time regression of HEAD over
branch-1-5.

I'd like to back out AS_SHELL_SANITIZE now, and maybe eventually add
AS_BOURNE_COMPATIBLE when we can assume Autoconf-2.60 (in a couple of
years).  Rationale: we can throw a bunch of its code out now, and the
resulting libtool script shows a noticeable speedup of the overall build
in some test code.  Also, this way we can be sure right now that the
code doesn't have the recent issues of AS_SHELL_SANITIZE any more
(certainly that argument will turn against me in due time; that's where
AS_BOURNE_COMPATIBLE should come into play).  This also has the
advantage that we may be certain that the CDPATH piece in libtool.m4 is
superfluous (we don't have to cater for older Autoconf versions any
more).

Then, there are a couple more low hanging fruit to kill: $SP2NL, $NL2SP,
whether `unset' works, all can be computed at configure time.  With all
of this in place, a mere
  $LIBTOOL -n --mode=compile $CC -c foo.c

is marginally faster with CVS HEAD than with branch-1-5 (both around
70ms on my test system), and takes about half as long as
  $LIBTOOL --mode=compile $CC -c foo.c

with an empty source file and gcc-3.4.4 (around 130ms).  Without this
patch, CVS HEAD ranges at about 140ms excluding the compiler, and 200ms
including it, so this actually halves the script overhead for compile
mode in the best case.  All of this at the expense of a slightly slower
and larger configure and config.status.

To put this in perspective: over here, this change makes running the old
part of the HEAD test suite take 4m38s instead of 5m53s.  :-))

Some rationale about why I don't think the expensive locale variable
treatment from Autoconf is necessary in Libtool: Autoconf tries to work
here even in the remote case that you're on IRIX, force configure to use
that borked shell that allows to set variables read-only, and also
actually have been stupid enough to set some of the locale variables
read-only.  If you meet someone that matches this description, point him
to this message, and tell him to get a clue.

Any reasons against applying this now?

FYI, in case you're starting to worry, I probably won't do more speedup
work before 2.0.

Cheers,
Ralf

        Fix mode=compile time regression of CVS HEAD over branch-1-5.

        * libltdl/m4/libtool.m4 (_LT_CHECK_XSI_SHELL): Rename to...
        (_LT_CHECK_SHELL_FEATURES): ...this.
        (_LT_SETUP): Adjust caller.
        (_LT_CHECK_XSI_SHELL): New libtool variables `lt_unset',
        `SP2NL', `NL2SP', to contain results from tests for unset,
        taken from AS_BOURNE_COMPATIBLE, and ASCII vs EBCDIC, taken...
        * libltdl/config/general.m4sh: ...from here, and used...
        * libltdl/config/ltmain.m4sh: ...here everywhere now.
        * (AS_SHELL_SANITIZE): Replace by faster, actually necessary
        part of its expansion, taken from current Autoconf CVS.  Do not
        save and set all locale variables any more, but only LANG,
        LC_ALL, LC_CTYPE, LC_COLLATE, LC_MESSAGES.
        (func_mode_execute): Adjust.
        * libltdl/m4/libtool.m4 (_LT_CONFIG): No need to unset CDPATH
        here any more.
        * libtoolize.m4sh: Compute `SP2NL' and `NL2SP' here, too.

Index: libltdl/config/general.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/general.m4sh,v
retrieving revision 1.3
diff -u -r1.3 general.m4sh
--- libltdl/config/general.m4sh 11 Jan 2006 17:24:56 -0000      1.3
+++ libltdl/config/general.m4sh 17 May 2006 17:12:38 -0000
@@ -105,19 +105,6 @@
 sed_double_backslash='s/^\(\(''\\\\''\\\\''\)*''\\\\''\)\$/\1\\$/;
                 s/\([[^\\]]\(''\\\\''\\\\''\)*''\\\\''\)\$/\1\\$/g'
 
-# test EBCDIC or ASCII
-case `echo X|tr X '\101'` in
- A) # ASCII based system
-    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
-  SP2NL='tr \040 \012'
-  NL2SP='tr \015\012 \040\040'
-  ;;
- *) # EBCDIC based system
-  SP2NL='tr \100 \n'
-  NL2SP='tr \r\n \100\100'
-  ;;
-esac
-
 # Standard options:
 opt_dry_run=false
 opt_help=false
Index: libltdl/config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.44
diff -u -r1.44 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  17 May 2006 01:58:40 -0000      1.44
+++ libltdl/config/ltmain.m4sh  17 May 2006 17:12:38 -0000
@@ -77,18 +77,34 @@
 TIMESTAMP="@TIMESTAMP@"
 address@hidden@
 
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
 # NLS nuisances: We save the old values to restore during execute mode.
-# AS_SHELL_SANITIZE will take care of unsetting.
-for lt_var in \
-  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
-  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
-  LC_TELEPHONE LC_TIME
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
 do
-  eval "test \"\${$lt_var+set}\" = set && save_$lt_var=\$$lt_var"
+  eval "if test \"\${$lt_var+set}\" = set; then
+          save_$lt_var=\$$lt_var
+          $lt_var=C
+         export $lt_var
+       fi"
 done
 
-AS_SHELL_SANITIZE
-$as_unset CDPATH
+$lt_unset CDPATH
 
 m4_include([getopt.m4sh])
 
@@ -1637,15 +1653,12 @@
       fi
 
       # Restore saved environment variables
-      for lt_var in \
-       LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
-       LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
-       LC_TELEPHONE LC_TIME
+      for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
       do
        eval "if test \"\${save_$lt_var+set}\" = set; then
                 $lt_var=\$save_$lt_var; export $lt_var
              else
-               $as_unset $lt_var
+               $lt_unset $lt_var
              fi"
       done
 
@@ -5793,7 +5806,7 @@
        # Preserve any variables that may affect compiler behavior
        for var in $variables_saved_for_relink; do
          if eval test -z \"\${$var+set}\"; then
-           relink_command="{ test -z \"\${$var+set}\" || unset $var || { 
$var=; export $var; }; }; $relink_command"
+           relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { 
$var=; export $var; }; }; $relink_command"
          elif eval var_value=\$$var; test -z "$var_value"; then
            relink_command="$var=; export $var; $relink_command"
          else
@@ -6534,7 +6547,7 @@
       # Preserve any variables that may affect compiler behavior
       for var in $variables_saved_for_relink; do
        if eval test -z \"\${$var+set}\"; then
-         relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; 
export $var; }; }; $relink_command"
+         relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { 
$var=; export $var; }; }; $relink_command"
        elif eval var_value=\$$var; test -z "$var_value"; then
          relink_command="$var=; export $var; $relink_command"
        else
Index: libltdl/m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/m4/libtool.m4,v
retrieving revision 1.66
diff -u -r1.66 libtool.m4
--- libltdl/m4/libtool.m4       17 May 2006 01:58:40 -0000      1.66
+++ libltdl/m4/libtool.m4       17 May 2006 17:12:39 -0000
@@ -145,7 +145,7 @@
 _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
 dnl
 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_CHECK_XSI_SHELL])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
 m4_require([_LT_CMD_RELOAD])dnl
 m4_require([_LT_CHECK_MAGIC_METHOD])dnl
 m4_require([_LT_CMD_OLD_ARCHIVE])dnl
@@ -683,10 +683,6 @@
 _LT_LIBTOOL_TAG_VARS
 # ### END LIBTOOL CONFIG
 
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
 _LT_EOF
 
   case $host_os in
@@ -6854,11 +6850,11 @@
 ])#m4_ifndef
 
 
-# _LT_CHECK_XSI_SHELL
-# -------------------
+# _LT_CHECK_SHELL_FEATURES
+# ------------------------
 # Find out whether the shell is Bourne or XSI compatible,
 # or has some other useful features.
-m4_defun([_LT_CHECK_XSI_SHELL],
+m4_defun([_LT_CHECK_SHELL_FEATURES],
 [AC_MSG_CHECKING([whether the shell understands some XSI constructs])
 # Try some XSI features
 xsi_shell=no
@@ -6876,7 +6872,29 @@
   && lt_shell_append=yes
 AC_MSG_RESULT([$lt_shell_append])
 _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
-])# _LT_CHECK_XSI_SHELL
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
+else
+  lt_unset=false
+fi
+_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
+  ;;
+esac
+_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
+_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
+])# _LT_CHECK_SHELL_FEATURES
 
 
 # _LT_PROG_XSI_SHELLFNS
Index: libtoolize.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libtoolize.m4sh,v
retrieving revision 1.53
diff -u -r1.53 libtoolize.m4sh
--- libtoolize.m4sh     21 Jan 2006 16:44:41 -0000      1.53
+++ libtoolize.m4sh     17 May 2006 11:04:30 -0000
@@ -70,6 +70,20 @@
 
 m4_include([getopt.m4sh])
 
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  SP2NL='tr \040 \012'
+  NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  SP2NL='tr \100 \n'
+  NL2SP='tr \r\n \100\100'
+  ;;
+esac
+
+
 # Command line options:
 opt_debug=:
 opt_force=false




reply via email to

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