autoconf-patches
[Top][All Lists]
Advanced

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

Re: Debian-specific Autoconf patches


From: Paul Eggert
Subject: Re: Debian-specific Autoconf patches
Date: Tue, 30 May 2006 00:41:08 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Ralf Wildenhues <address@hidden> writes:

> this is horrendously ugly, but look:
>
>   if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> 
> $nlist) && test -s "$nlist"; then

Just this line alone doesn't explain why the change would break this
usage.  Unless perhaps $lt_cv_sys_global_symbol_pipe expands into some
horrible string value with unescaped '"'?  (That certainly would
explain your "horrendous". :-)

> What am I going to replace the above with, so it works with both
> Autoconf versions, pre- and post this change?

I don't have an answer for you, partly because I don't understand the
example.  However, I'll take your word for it that the change breaks
something somehow.

> let's revert this part of the patch, and post-2.60, let's
> create _differently named_ macros which are actually safe,

I'm not sure we can come up with safe ones, not without a major
rewrite (e.g., use shell functions).  However, it shouldn't hurt to
bring back AC_TRY_COMMAND and AC_TRY_EVAL with their old meanings.
Presumably that would fix the above example.

> (Autoconf hasn't worried about potential hazards for years,

I'm not particularly worried about these hazards being run into by
accident.  I'm worried about their deliberate misuse.  (I'd rather not
think too hard about how to misuse them.  :-)

> I don't feel good if on the one hand we're not presenting people with a
> AC_CONFIG_SUBDIRS macro that fulfills their needs

Yes, we should do that in a future version.

Anyway, I installed this to bring back the old AC_TRY_COMMAND and
AC_TRY_EVAL.  If this doesn't address the problem please let me know.

2006-05-30  Paul Eggert  <address@hidden>

        * lib/autoconf/general.m4: Revert AC_TRY_EVAL and AC_TRY_COMMAND,
        since evidently some packages rely on the old, broken behavior.
        Problem reported by Ralf Wildenhues in
        
<http://lists.gnu.org/archive/html/autoconf-patches/2006-05/msg00160.html>.
        (AC_TRY_EVAL, AC_TRY_COMMAND, _AC_EVAL): Go back to the
        pre-2006-05-26 definitions, but leave in the comments that
        these macros are dangerous and should not be used.
        (_AC_DO_ECHO): Renamed from _AC_EVAL_ECHO.  All callers changed.
        (_AC_DO): Renamed from _AC_EVAL.  All callers changed.
        (_AC_DO_STDERR): Renamed from _AC_EVAL_STDERR.  All callers changed.
        (_AC_DO_VAR): Renamed from AC_TRY_EVAL.
        (_AC_DO_TOKENS): Renamed from AC_TRY_COMMAND.

Index: lib/autoconf/c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.228
diff -p -u -r1.228 c.m4
--- lib/autoconf/c.m4   26 May 2006 22:29:50 -0000      1.228
+++ lib/autoconf/c.m4   30 May 2006 07:18:13 -0000
@@ -543,9 +543,9 @@ test -z "$CC" && AC_MSG_FAILURE([no acce
 # Provide some information about the compiler.
 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
 ac_compiler=`set X $ac_compile; echo $[2]`
-_AC_EVAL([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
+_AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
+_AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
+_AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
 
 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
@@ -641,17 +641,17 @@ AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
 # existing .o file with -o, though they will create one.
 ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
 rm -f conftest2.*
-if AC_TRY_EVAL(ac_try) &&
-   test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
+if _AC_DO_VAR(ac_try) &&
+   test -f conftest2.$ac_objext && _AC_DO_VAR(ac_try);
 then
   eval ac_cv_prog_cc_${ac_cc}_c_o=yes
   if test "x$CC" != xcc; then
     # Test first that cc exists at all.
-    if AC_TRY_COMMAND(cc -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD); then
+    if _AC_DO_TOKENS(cc -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD); then
       ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext 
>&AS_MESSAGE_LOG_FD'
       rm -f conftest2.*
-      if AC_TRY_EVAL(ac_try) &&
-        test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
+      if _AC_DO_VAR(ac_try) &&
+        test -f conftest2.$ac_objext && _AC_DO_VAR(ac_try);
       then
        # cc works too.
        :
@@ -771,9 +771,9 @@ fi
 # Provide some information about the compiler.
 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
 ac_compiler=`set X $ac_compile; echo $[2]`
-_AC_EVAL([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
+_AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
+_AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
+_AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
 
 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
@@ -840,9 +840,9 @@ AC_CACHE_CHECK([whether $CXX understands
 # `.o' file with `-o', although they will create one.
 ac_try='$CXX $CXXFLAGS -c conftest.$ac_ext -o conftest2.$ac_objext 
>&AS_MESSAGE_LOG_FD'
 rm -f conftest2.*
-if AC_TRY_EVAL(ac_try) &&
+if _AC_DO_VAR(ac_try) &&
      test -f conftest2.$ac_objext &&
-     AC_TRY_EVAL(ac_try); then
+     _AC_DO_VAR(ac_try); then
   ac_cv_prog_cxx_c_o=yes
 else
   ac_cv_prog_cxx_c_o=no
@@ -934,9 +934,9 @@ AC_CHECK_TOOLS(OBJC,
 # Provide some information about the compiler.
 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
 ac_compiler=`set X $ac_compile; echo $[2]`
-_AC_EVAL([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
+_AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
+_AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
+_AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
 
 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
Index: lib/autoconf/fortran.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/fortran.m4,v
retrieving revision 1.209
diff -p -u -r1.209 fortran.m4
--- lib/autoconf/fortran.m4     26 May 2006 22:29:50 -0000      1.209
+++ lib/autoconf/fortran.m4     30 May 2006 07:18:14 -0000
@@ -364,9 +364,9 @@ AC_CHECK_TOOLS([]_AC_FC[],
 # Provide some information about the compiler.
 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
 ac_compiler=`set X $ac_compile; echo $[2]`
-_AC_EVAL([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
-_AC_EVAL([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
+_AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
+_AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
+_AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
 rm -f a.out
 
 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
@@ -463,9 +463,9 @@ AC_CACHE_CHECK([whether $[]_AC_FC[] unde
 # `.o' file with `-o', although they will create one.
 ac_try='$[]_AC_FC[] $[]_AC_LANG_PREFIX[]FLAGS -c conftest.$ac_ext -o 
conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
 rm -f conftest2.*
-if AC_TRY_EVAL(ac_try) &&
+if _AC_DO_VAR(ac_try) &&
      test -f conftest2.$ac_objext &&
-     AC_TRY_EVAL(ac_try); then
+     _AC_DO_VAR(ac_try); then
   ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o=yes
 else
   ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o=no
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.920
diff -p -u -r1.920 general.m4
--- lib/autoconf/general.m4     26 May 2006 22:29:50 -0000      1.920
+++ lib/autoconf/general.m4     30 May 2006 07:18:14 -0000
@@ -2143,10 +2143,10 @@ AC_DEFUN([_AC_RUN_LOG_STDERR],
   _AS_ECHO_LOG([\$? = $ac_status])
   (exit $ac_status); }])
 
-# _AC_EVAL_ECHO(COMMAND)
-# ----------------------
+# _AC_DO_ECHO(COMMAND)
+# --------------------
 # Echo COMMAND.  This is designed to be used just before evaluating COMMAND.
-AC_DEFUN([_AC_EVAL_ECHO],
+AC_DEFUN([_AC_DO_ECHO],
 [m4_if([$1], [$ac_try], [], [ac_try="$1"
 ])dnl
 dnl If the string contains '${', '"', '`', or '\', then escape
@@ -2159,42 +2159,76 @@ case $ac_try in #(
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try\""])
 
-# _AC_EVAL(COMMAND)
-# -----------------
+# _AC_DO(COMMAND)
+# ---------------
 # Eval COMMAND, save the exit status in ac_status, and log it.
-AC_DEFUN([_AC_EVAL],
+# For internal use only.
+AC_DEFUN([_AC_DO],
 [_AC_RUN_LOG([eval "$1"],
-            [_AC_EVAL_ECHO([$1])])])
+            [_AC_DO_ECHO([$1])])])
 
 
-# _AC_EVAL_STDERR(COMMAND)
-# ------------------------
+# _AC_DO_STDERR(COMMAND)
+# ----------------------
 # Like _AC_RUN_LOG_STDERR, but eval (instead of running) COMMAND.
-AC_DEFUN([_AC_EVAL_STDERR],
+AC_DEFUN([_AC_DO_STDERR],
 [_AC_RUN_LOG_STDERR([eval "$1"],
-                   [_AC_EVAL_ECHO([$1])])])
+                   [_AC_DO_ECHO([$1])])])
+
+
+# _AC_DO_VAR(VARIABLE)
+# --------------------
+# Evaluate "$VARIABLE", which should be a valid shell command.
+# The purpose of this macro is to write "configure:123: command line"
+# into config.log for every test run.
+AC_DEFUN([_AC_DO_VAR],
+[_AC_DO([$$1])])
+
+
+# _AC_DO_TOKENS(COMMAND)
+# ----------------------
+# Like _AC_DO_VAR, but execute COMMAND instead, where COMMAND is a series of
+# tokens of the shell command language.
+AC_DEFUN([_AC_DO_TOKENS],
+[{ ac_try='$1'
+  _AC_DO([$ac_try]); }])
+
+
+# _AC_EVAL(COMMAND)
+# -----------------
+# Eval COMMAND, save the exit status in ac_status, and log it.
+# Unlike _AC_DO, this macro mishandles quoted arguments in some cases.
+# It is present only to support the backward-compatibility macros
+# AC_TRY_EVAL and AC_TRY_COMMAND.
+AC_DEFUN([_AC_EVAL],
+[_AC_RUN_LOG([eval $1],
+            [eval echo "$as_me:$LINENO: \"$1\""])])
 
 
 # AC_TRY_EVAL(VARIABLE)
 # ---------------------
-# Evaluate "$VARIABLE", which should be a valid shell command.
-# The purpose of this macro is to "configure:123: command line"
-# written into config.log for every test run.
-# This macro is dangerous, and should not be used outside Autoconf, since not
-# every shell command will work due to problems with eval and quoting,
-# and the rules for exactly what does work are tricky.
-# This macro may be removed in a future release.
+# Evaluate $VARIABLE, which should be a valid shell command.
+# The purpose of this macro is to write "configure:123: command line"
+# into config.log for every test run.
+#
+# The AC_TRY_EVAL and AC_TRY_COMMAND macros are dangerous and
+# undocumented, and should not be used.
+# They may be removed or their API changed in a future release.
+# Autoconf itself no longer uses these two macros; they are present
+# only for backward compatibility with previous versions of Autoconf.
+# Not every shell command will work due to problems with eval
+# and quoting, and the rules for exactly what does work are tricky.
+# Worse, due to double-expansion during evaluation, arbitrary unintended
+# shell commands could be executed in some situations.
 AC_DEFUN([AC_TRY_EVAL],
 [_AC_EVAL([$$1])])
 
 
 # AC_TRY_COMMAND(COMMAND)
 # -----------------------
-# Like AC_TRY_EVAL, but execute the string COMMAND instead.
-# This macro is dangerous, and should not be used outside Autoconf, since not
-# every shell command will work due to problems with eval and quoting,
-# and the rules for exactly what does work are tricky.
-# This macro may be removed in a future release.
+# Like AC_TRY_EVAL, but execute COMMAND instead, where COMMAND is a series of
+# tokens of the shell command language.
+# This macro should not be used; see the comments under AC_TRY_EVAL for why.
 AC_DEFUN([AC_TRY_COMMAND],
 [{ ac_try='$1'
   _AC_EVAL([$ac_try]); }])
@@ -2226,7 +2260,7 @@ AC_DEFUN([AC_RUN_LOG],
 # to expand ac_cpp.
 AC_DEFUN([_AC_PREPROC_IFELSE],
 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
-if _AC_EVAL_STDERR([$ac_cpp conftest.$ac_ext]) >/dev/null; then
+if _AC_DO_STDERR([$ac_cpp conftest.$ac_ext]) >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag
     ac_cpp_err=$ac_cpp_err$ac_[]_AC_LANG_ABBREV[]_werror_flag
@@ -2305,9 +2339,9 @@ AC_DEFUN([AC_EGREP_HEADER],
 m4_define([_AC_COMPILE_IFELSE],
 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
 rm -f conftest.$ac_objext
-AS_IF([_AC_EVAL_STDERR($ac_compile) &&
-        AC_TRY_COMMAND([test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || test 
! -s conftest.err]) &&
-        AC_TRY_COMMAND([test -s conftest.$ac_objext])],
+AS_IF([_AC_DO_STDERR($ac_compile) &&
+        _AC_DO_TOKENS([test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || test ! 
-s conftest.err]) &&
+        _AC_DO_TOKENS([test -s conftest.$ac_objext])],
       [$2],
       [_AC_MSG_LOG_CONFTEST
        $3])
@@ -2345,9 +2379,9 @@ AU_DEFUN([AC_TRY_COMPILE],
 m4_define([_AC_LINK_IFELSE],
 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
 rm -f conftest.$ac_objext conftest$ac_exeext
-AS_IF([_AC_EVAL_STDERR($ac_link) &&
-        AC_TRY_COMMAND([test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || test 
! -s conftest.err]) &&
-        AC_TRY_COMMAND([test -s conftest$ac_exeext])],
+AS_IF([_AC_DO_STDERR($ac_link) &&
+        _AC_DO_TOKENS([test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || test ! 
-s conftest.err]) &&
+        _AC_DO_TOKENS([test -s conftest$ac_exeext])],
       [$2],
       [_AC_MSG_LOG_CONFTEST
        $3])
@@ -2399,7 +2433,7 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]], 
 m4_define([_AC_RUN_IFELSE],
 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
 rm -f conftest$ac_exeext
-AS_IF([AC_TRY_EVAL(ac_link) && AC_TRY_COMMAND(./conftest$ac_exeext)],
+AS_IF([_AC_DO_VAR(ac_link) && _AC_DO_TOKENS(./conftest$ac_exeext)],
       [$2],
       [echo "$as_me: program exited with status $ac_status" >&AS_MESSAGE_LOG_FD
 _AC_MSG_LOG_CONFTEST
Index: lib/autoconf/lang.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/lang.m4,v
retrieving revision 1.182
diff -p -u -r1.182 lang.m4
--- lib/autoconf/lang.m4        26 May 2006 17:25:36 -0000      1.182
+++ lib/autoconf/lang.m4        30 May 2006 07:18:14 -0000
@@ -380,7 +380,7 @@ AC_BEFORE([$0], [AC_LINK_IFELSE])
 
 m4_define([_AC_COMPILER_EXEEXT],
 [AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
-if AC_TRY_EVAL(ac_link); then
+if _AC_DO_VAR(ac_link); then
   ac_no_link=no
   ]m4_defn([_AC_COMPILER_EXEEXT])[
 else
@@ -494,7 +494,7 @@ do
 done
 rm -f $ac_rmfiles
 
-AS_IF([AC_TRY_EVAL(ac_link_default)],
+AS_IF([_AC_DO_VAR(ac_link_default)],
 [# Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
 # So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
 # in a Makefile.  We should not override ac_cv_exeext if it was cached,
@@ -543,7 +543,7 @@ AC_MSG_CHECKING([whether the _AC_LANG co
 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
 # If not cross compiling, check that we can run a simple program.
 if test "$cross_compiling" != yes; then
-  if AC_TRY_COMMAND([./$ac_file]); then
+  if _AC_DO_TOKENS([./$ac_file]); then
     cross_compiling=no
   else
     if test "$cross_compiling" = maybe; then
@@ -574,7 +574,7 @@ AC_MSG_RESULT([$cross_compiling])
 # as computed by _AC_COMPILER_EXEEXT_DEFAULT is OK.
 m4_define([_AC_COMPILER_EXEEXT_O],
 [AC_MSG_CHECKING([for suffix of executables])
-AS_IF([AC_TRY_EVAL(ac_link)],
+AS_IF([_AC_DO_VAR(ac_link)],
 [# If both `conftest.exe' and `conftest' are `present' (well, observable)
 # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
 # work properly (i.e., refer to `conftest.exe'), while it won't with
@@ -636,7 +636,7 @@ m4_define([_AC_COMPILER_OBJEXT],
 [AC_CACHE_CHECK([for suffix of object files], ac_cv_objext,
 [AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
 rm -f conftest.o conftest.obj
-AS_IF([AC_TRY_EVAL(ac_compile)],
+AS_IF([_AC_DO_VAR(ac_compile)],
 [for ac_file in conftest.o conftest.obj conftest.*; do
   test -f "$ac_file" || continue;
   case $ac_file in
Index: lib/autoconf/programs.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/programs.m4,v
retrieving revision 1.58
diff -p -u -r1.58 programs.m4
--- lib/autoconf/programs.m4    27 May 2006 02:54:33 -0000      1.58
+++ lib/autoconf/programs.m4    30 May 2006 07:18:14 -0000
@@ -720,7 +720,7 @@ cat >conftest.l <<_ACEOF
 %%
 %%
 _ACEOF
-AC_TRY_EVAL(LEX conftest.l)
+_AC_DO_VAR(LEX conftest.l)
 if test -f lex.yy.c; then
   ac_cv_prog_lex_root=lex.yy
 elif test -f lexyy.c; then





reply via email to

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