[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible patch for autoconf?
From: |
Akim Demaille |
Subject: |
Re: Possible patch for autoconf? |
Date: |
10 May 2001 19:28:05 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Cuyahoga Valley) |
>>>>> "Daniel" == Daniel Carroll <address@hidden> writes:
Daniel> After thinking about it some more, I believe that the outer
Daniel> _AC_PREPROC_IFELSE is going down the "else" codepath (which
Daniel> calls "m4_default([$2], :)"), because it considers the
Daniel> AC_LANG_SOURCE(address@hidden:@include <assert.h> Syntax error]])
Daniel> construct to have failed for "cc -E" (because $ac_cpp_err is
Daniel> set to "maybe").
Hm... Indeed. Then maybe (how this word sounds bad...) it simply
means the `maybe' assignment was badly placed?
Well, this code is too complex. We struggle too much with it, let's
rewrite it completely. What do you people think about this?
# _AC_PROG_PREPROC_WORKS_IFELSE(IF-WORKS, IF-NOT)
# -----------------------------------------------
# Check if $ac_cpp is a working preprocessor that can flag absent
# includes either by the exit status or by warnings.
# Set ac_cpp_err to a non-empty value if the preprocessor failed.
# This macro is for all languages, not only C.
AC_DEFUN([_AC_PROG_PREPROC_WORKS_IFELSE],
[ac_preproc_ok=false
for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
_AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include <assert.h>
Syntax error]])],
[],
[# Broken: fails on valid input.
continue])
# OK, works on sane cases. Now check whether non-existent headers
# can be detected and how.
_AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include
<ac_nonexistent.h>]])],
[# Broken: success on invalid input.
continue],
[# Passes both tests.
ac_preproc_ok=:
break])
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
AS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE
Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.127
diff -u -u -r1.127 aclang.m4
--- aclang.m4 2001/04/27 13:32:52 1.127
+++ aclang.m4 2001/05/10 17:18:01
@@ -832,30 +832,33 @@
# Set ac_cpp_err to a non-empty value if the preprocessor failed.
# This macro is for all languages, not only C.
AC_DEFUN([_AC_PROG_PREPROC_WORKS_IFELSE],
-[# We don't know yet if stderr is the criterion (vs exit status).
-ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag=maybe
+[ac_preproc_ok=false
+for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ _AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include <assert.h>
+ Syntax error]])],
+ [],
+ [# Broken: fails on valid input.
+continue])
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ _AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include
<ac_nonexistent.h>]])],
+ [# Broken: success on invalid input.
+continue],
+ [# Passes both tests.
+ac_preproc_ok=:
+break])
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+AS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE
-# Use a header file that comes with gcc, so configuring glibc
-# with a fresh cross-compiler works.
-# On the NeXT, cc -E runs the code through the compiler's parser,
-# not just through cpp. "Syntax error" is here to catch this case.
-_AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include <assert.h>
-Syntax error]])],
-[# OK, works on sane cases. Now check whether non-existent headers can
-# be detected and how.
-_AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include
<ac_nonexistent.h>]])],
-[# Broken: cannot detect missing includes.
-m4_default([$2], :)],
-[# OK, detects failures. How?
-if test "x$ac_cpp_err" = xmaybe; then
- ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag=yes
-else
- ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag=
-fi
-$1])],
- [# Broken: fails on valid input.
-m4_default([$2], :)])])# _AC_PROG_PREPROC_WORKS_IFELSE
-
# AC_PROG_CPP
# -----------
@@ -878,7 +881,8 @@
# Double quotes because CPP needs to be expanded
for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
do
- _AC_PROG_PREPROC_WORKS_IFELSE([break])
+ # break 2 since there is a loop in there.
+ _AC_PROG_PREPROC_WORKS_IFELSE([break 2])
done
ac_cv_prog_CPP=$CPP
])dnl
@@ -1085,7 +1089,8 @@
# Double quotes because CXXCPP needs to be expanded
for CXXCPP in "$CXX -E" "/lib/cpp"
do
- _AC_PROG_PREPROC_WORKS_IFELSE([break])
+ # break 2 since there is a loop in there.
+ _AC_PROG_PREPROC_WORKS_IFELSE([break 2])
done
ac_cv_prog_CXXCPP=$CXXCPP
])dnl
Index: tests/compile.at
===================================================================
RCS file: /cvs/autoconf/tests/compile.at,v
retrieving revision 1.19
diff -u -u -r1.19 compile.at
--- tests/compile.at 2001/05/10 15:41:18 1.19
+++ tests/compile.at 2001/05/10 17:18:02
@@ -171,6 +171,7 @@
# Ignore if /lib/cpp doesn't work
AT_CHECK([/lib/cpp </dev/null || exit 77], [], [ignore], [ignore])
+# A cpp which exit status is meaningless.
AT_DATA([mycpp],
[[#! /bin/sh
/lib/cpp ${1+"$@"}
@@ -212,30 +213,27 @@
echo "Annoying copyright message" >&2
if test "$1" != "-E"; then
exec cc $*
+elif test "$2" = "-traditional-cpp"; then
+ exec cc $*
else
- if test "$2" = "-traditional-cpp"; then
- exec cc $*
- else
- exec /lib/cpp ${1+"$@"}
- fi
+ exec /lib/cpp ${1+"$@"}
fi
]])
chmod +x mycc
+# We go through the following contortions, in order to have the
+# configure script go down the same codepaths as it would during a
+# normal CPP selection check. If we explicitly set CPP, it goes down
+# a different codepath.
_AT_CHECK_AC_MACRO(
-[[# We go through the following contortions, in order to
-# have the configure script go down the same codepaths
-# as it would during a normal CPP selection check. If
-# we explicitly set CPP, it goes down a different codepath.
-CC=mycc
+[[CC=./mycc
AC_PROG_CPP
# The test $CC compiler should have been selected.
-test "$CPP" != "mycc -E" &&
+test "$CPP" != "$CC -E" &&
AC_MSG_ERROR([error messages on stderr cause the preprocessor selection to
fail])
-# If the preprocessor is not strict, just ignore
-test "x$ac_c_preproc_warn_flag" = xyes &&
- AC_MSG_ERROR([preprocessor has no warning option], 77)
+
+# Exercise CPP.
AC_CHECK_HEADERS(stdio.h autoconf_io.h)]])
AT_CHECK_DEFINES(
Note there is still a problem with the test suite itself: we should
_not_ run cc like this. At least we should AC_PROG_CC to find the $CC
to pass to mycc, just as for the CPP test. Left as an exercise :)