[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_PROG_CC_* shouldn't append multiple options
From: |
Paul Eggert |
Subject: |
Re: AC_PROG_CC_* shouldn't append multiple options |
Date: |
Thu, 20 Sep 2012 14:35:36 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 |
Thanks for mentiong that. This area is a bit of a mess, so I took the
liberty of addressing that issue by doing one of the things on the TODO
list, and pushed the following patch into the autoconf master. Please
let me know if you have problems.
>From 9b8be34ae9ffb23d1ec269524d4f3aed82f77899 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Thu, 20 Sep 2012 14:32:06 -0700
Subject: [PATCH] AC_PROG_CC_STDC: fold into AC_PROG_CC, removing C11 macro
* NEWS:
* doc/autoconf.texi (C Compiler): Document the following.
* lib/autoconf/c.m4 (AC_PROG_CC): Check for the latest C version
supported, not just C89.
(_AC_C_STD_TRY): Keep track of the options we add to bring
the C compiler up to standard, so that we can undo it if the
user later requests some other C standard.
(_AC_PROG_CC_FORCE_VERSION): New macro.
(AC_PROG_CC_C89, AC_PROG_CC_C99): Use it. These macros now
have a documented side effect of changing the C version requested.
(AC_PROG_CC_C11): Remove. It wasn't useful.
(AC_PROG_CC_STDC): Now an obsolescent alias for AC_PROG_CC.
(AC_C_PROTOTYPES): Allow any standard C version, not just c89.
Don't chatter, since we don't actually run any checking code.
* lib/autoconf/types.m4 (AC_TYPE_LONG_LONG_INT)
(AC_TYPE_UNSIGNED_LONG_LONG_INT): Treat C11 like C99.
* TODO: Remove the TODO item corresponding to the above.
---
NEWS | 9 ++++--
TODO | 12 ++------
doc/autoconf.texi | 65 ++++++++++++++++-------------------------
lib/autoconf/c.m4 | 80 +++++++++++++++++++++++++++------------------------
lib/autoconf/types.m4 | 76 +++++++++++++++++++++++++-----------------------
5 files changed, 116 insertions(+), 126 deletions(-)
diff --git a/NEWS b/NEWS
index 7c1e77e..bea8911 100644
--- a/NEWS
+++ b/NEWS
@@ -7,10 +7,13 @@ GNU Autoconf NEWS - User visible changes.
** Macros
-- New macro AC_PROG_CC_C11.
+- AC_PROG_CC now prefers C11 if available, falling back on C99 and
+ then on C89 as before. (There is no AC_PROG_CC_C11 macro, as no
+ need for one has been identified.)
-- AC_PROG_CC_STDC now prefers C11 if available, falling back on C99
- and then on C89 as before.
+- It is now documented that AC_PROG_CC_C89 and AC_PROG_CC_C99
+ interfere with each other and with AC_PROG_CC. Applications should
+ normally use AC_PROG_CC.
- AC_FUNC_VFORK now checks for the signal-handling bug in Solaris 2.4 'vfork'.
Formerly, it ignored this bug, so that Emacs could use some tricky
diff --git a/TODO b/TODO
index cb124b2..af1385c 100644
--- a/TODO
+++ b/TODO
@@ -34,14 +34,6 @@ be performed in another file than confdefs.h, say confh.h,
which is
used for config.h generation, but not used in configure's own tests.
** AC_PROG_CC
-Currently it tries to put the C compiler in ANSI C mode by default.
-We should change this spec so that AC_PROG_CC tries to change the
-compiler to be the "nicest" mode, i.e. support for the latest standard
-features (currently ISO C99) plus support for all vendor extensions,
-even if they are slightly incompatible with C99. The basic idea here
-is that AC_PROG_CC should disable pedanticisms and should enable
-extensions.
-
Have a way to specify different default flags to try; see this thread
for more information:
<http://lists.gnu.org/archive/html/bug-autoconf/2008-08/msg00009.html>.
@@ -143,7 +135,9 @@ We also need to check the srcext which are supported by the
compiler.
In fact, this macro is also probably the right place to check for
objext and exeext.
-** AC_PROG_CC_STDC
+** AC_PROG_CC
+How should the desired ISO version be specified? AC_PROG_CC_C89
+do not play well with each other, or with AC_PROG_CC.
Should be: AC_PROG_CC_ISO? Or even more specific for the ISO version?
Should include more tests (e.g., AC_C_CONST etc.)? See Peter for very
useful comments on the technology. Should we make this a new
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 611b675..86b31ee 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -7223,13 +7223,14 @@ makes this invalid. That is why Autoconf stopped
issuing
@code{#line} directives.
@end table
address@hidden
@defmac AC_PROG_CC (@ovar{compiler-search-list})
@acindex{PROG_CC}
@evindex CC
@evindex CFLAGS
@ovindex CC
@ovindex CFLAGS
address@hidden prog_cc_c89
address@hidden prog_cc_stdc
Determine a C compiler to use. If @code{CC} is not already set in the
environment, check for @code{gcc} and @code{cc}, then for other C
compilers. Set output variable @code{CC} to the name of the compiler
@@ -7246,16 +7247,14 @@ this:
AC_PROG_CC([gcc cl cc])
@end example
-If the C compiler does not handle function prototypes correctly by
-default, try to add an option to output variable @code{CC} to make it
-so. This macro tries various options that select standard-conformance
-modes on various systems.
-
+If the C compiler cannot compile ISO Standard C (currently
+C11), try to add an option to output variable @code{CC} to make it work.
+If the compiler does not support C11, fall back to supporting
+ISO C99; if C99 does not work, fall back to ANSI C89 (ISO C90).
+When testing for ISO C versions, use GNU extensions if available.
After calling this macro you can check whether the C compiler has been
-set to accept ANSI C89 (ISO C90); if not, the shell
-variable
address@hidden is set to @samp{no}. See also
address@hidden below.
+set to accept Standard C; if not, the shell variable
address@hidden is set to @samp{no}.
If using the GNU C compiler, set shell variable @code{GCC} to
@samp{yes}. If output variable @code{CFLAGS} was not already set, set
@@ -7324,19 +7323,6 @@ features. To check for characteristics not listed here,
use
@code{AC_COMPILE_IFELSE} (@pxref{Running the Compiler}) or
@code{AC_RUN_IFELSE} (@pxref{Runtime}).
address@hidden AC_PROG_CC_STDC
address@hidden
address@hidden prog_cc_stdc
-If the C compiler cannot compile ISO Standard C (currently
-C11), try to add an option to output variable @code{CC} to make it work.
-If the compiler does not support C11, fall back to supporting
-ISO C99; if C99 does not work, fall back to ANSI C89 (ISO C90).
-
-After calling this macro you can check whether the C compiler has been
-set to accept Standard C; if not, the shell variable
address@hidden is set to @samp{no}.
address@hidden defmac
-
@defmac AC_PROG_CC_C89
@acindex{PROG_CC_C89}
@caindex prog_cc_c89
@@ -7351,7 +7337,9 @@ After calling this macro you can check whether the C
compiler has been
set to accept ANSI C89; if not, the shell variable
@code{ac_cv_prog_cc_c89} is set to @samp{no}.
-This macro is called automatically by @code{AC_PROG_CC}.
+This macro is rarely needed. It should be used only if your application
+requires C89 and will not work in later C versions. Typical applications
+should use @code{AC_PROG_CC} instead.
@end defmac
@defmac AC_PROG_CC_C99
@@ -7371,23 +7359,13 @@ in @code{for} loops, and variable length arrays.
After calling this macro you can check whether the C compiler has been
set to accept C99; if not, the shell variable
@code{ac_cv_prog_cc_c99} is set to @samp{no}.
address@hidden defmac
address@hidden AC_PROG_CC_C11
address@hidden
address@hidden prog_cc_c11
-If the C compiler is not in C11 mode by default, try to add an
-option to output variable @code{CC} to make it so. This macro tries
-various options that select C11 on some system or another, preferring
-extended functionality modes over strict conformance modes. Currently it
-considers the compiler to be in C11 mode if it handles @code{_Alignas},
address@hidden, @code{_Noreturn}, @code{_Static_assert}, UTF-8 string
-literals, duplicate @code{typedef}s, and anonymous structures and
-unions.
+This macro is rarely needed. It should be used only if your application
+requires C99 and will not work in later C versions. Typical applications
+should use @code{AC_PROG_CC} instead.
-After calling this macro you can check whether the C compiler has been
-set to accept C11; if not, the shell variable
address@hidden is set to @samp{no}.
+There is no @code{AC_PROG_CC_C11} macro, as no need for one has been
+identified.
@end defmac
@defmac AC_C_BACKSLASH_A
@@ -14389,8 +14367,8 @@ C variables in libraries.
After the category comes the name of the particular feature being
tested. Any further words in the macro name indicate particular aspects
-of the feature. For example, @code{AC_PROG_CC_STDC} checks whether the
-C compiler supports ISO Standard C.
+of the feature. For example, @code{AC_PROG_MAKE_SET} checks whether
address@hidden sets a variable to its own name.
An internal macro should have a name that starts with an underscore;
Autoconf internals should therefore start with @samp{_AC_}.
@@ -23678,6 +23656,11 @@ Replaced by @code{AC_TYPE_PID_T}
(@pxref{AC_TYPE_PID_T}).
Replaced by @code{AC_PREFIX_PROGRAM} (@pxref{AC_PREFIX_PROGRAM}).
@end defmac
address@hidden AC_PROG_CC_STDC
address@hidden
+Now done by @code{AC_PROG_CC} (@pxref{AC_PROG_CC}).
address@hidden defmac
+
@defmac AC_PROGRAMS_CHECK
@acindex{PROGRAMS_CHECK}
Replaced by @code{AC_CHECK_PROGS} (@pxref{AC_CHECK_PROGS}).
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index e994609..614d9b7 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -478,7 +478,19 @@ else
GCC=
fi
_AC_PROG_CC_G
-_AC_PROG_CC_C89
+dnl
+dnl Set ac_prog_cc_stdc to the supported C version.
+dnl Also set the documented variable ac_cv_prog_cc_stdc;
+dnl its name was chosen when it was cached, but it is no longer cached.
+_AC_PROG_CC_C11([ac_prog_cc_stdc=c11
+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11],
+ [_AC_PROG_CC_C99([ac_prog_cc_stdc=c99
+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
+ [_AC_PROG_CC_C89([ac_prog_cc_stdc=c89
+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
+ [ac_prog_cc_stdc=no
+ ac_cv_prog_cc_stdc=no])])])
+dnl
AC_LANG_POP(C)dnl
])# AC_PROG_CC
@@ -1166,13 +1178,15 @@ done
rm -f conftest.$ac_ext
CC=$ac_save_CC
])# AC_CACHE_VAL
+ac_prog_cc_stdc_options=
case "x$ac_cv_prog_cc_$1" in
x)
AC_MSG_RESULT([none needed]) ;;
xno)
AC_MSG_RESULT([unsupported]) ;;
*)
- CC="$CC $ac_cv_prog_cc_$1"
+ ac_prog_cc_stdc_options=" $ac_cv_prog_cc_$1"
+ CC=$CC$ac_prog_cc_stdc_options
AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
esac
AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
@@ -1423,47 +1437,43 @@ dnl with extended modes being tried first.
])# _AC_PROG_CC_C11
-# AC_PROG_CC_C89
-# --------------
-AC_DEFUN([AC_PROG_CC_C89],
+# _AC_PROG_CC_FORCE_VERSION(LOWER-VERSION, UPPER-VERSION)
+# -------------------------------------------------------
+# Require a compiler for a particular version of C, either C89 or C99.
+# LOWER-VERSION uses lower-case c, UPPER-VERSION uses upper-case.
+AC_DEFUN([_AC_PROG_CC_FORCE_VERSION],
[ AC_REQUIRE([AC_PROG_CC])dnl
- _AC_PROG_CC_C89
+ if test $ac_prog_cc_stdc != $1; then
+ ac_save_std_CC=$CC
+ if test -n "$ac_prog_cc_stdc_options"; then
+ CC=`expr "X$CC" : 'X\(.*\)'"$ac_prog_cc_stdc_options"
+ ``expr "X$CC" : ".*$ac_prog_cc_stdc_options"'\(.*\)'
+ `
+ fi
+ _AC_PROG_CC_$2(
+ [ac_prog_cc_stdc=$1
+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_$1],
+ [CC=$ac_save_std_CC
+ AC_MSG_WARN([$2 compiler not available; falling back on $CC])])
+ fi
])
+# AC_PROG_CC_C89
+# --------------
+AC_DEFUN([AC_PROG_CC_C89], [_AC_PROG_CC_FORCE_VERSION([c89], [C89])])
# AC_PROG_CC_C99
# --------------
-AC_DEFUN([AC_PROG_CC_C99],
-[ AC_REQUIRE([AC_PROG_CC])dnl
- _AC_PROG_CC_C99
-])
+AC_DEFUN([AC_PROG_CC_C99], [_AC_PROG_CC_FORCE_VERSION([c99], [C99])])
-
-# AC_PROG_CC_C11
-# --------------
-AC_DEFUN([AC_PROG_CC_C11],
-[ AC_REQUIRE([AC_PROG_CC])dnl
- _AC_PROG_CC_C11
-])
+# There is no AC_PROG_CC_C11, as we have not identified a need for it.
+# Applications should use AC_PROG_CC instead.
# AC_PROG_CC_STDC
# ---------------
-AC_DEFUN([AC_PROG_CC_STDC],
-[ AC_REQUIRE([AC_PROG_CC])dnl
- AS_CASE([$ac_cv_prog_cc_stdc],
- [no], [ac_cv_prog_cc_c11=no; ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no],
- [_AC_PROG_CC_C11([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11],
- [_AC_PROG_CC_C99([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
- [_AC_PROG_CC_C89([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
- [ac_cv_prog_cc_stdc=no])])])])
- AC_MSG_CHECKING([for $CC option to accept ISO Standard C])
- AC_CACHE_VAL([ac_cv_prog_cc_stdc], [])
- AS_CASE([$ac_cv_prog_cc_stdc],
- [no], [AC_MSG_RESULT([unsupported])],
- [''], [AC_MSG_RESULT([none needed])],
- [AC_MSG_RESULT([$ac_cv_prog_cc_stdc])])
-])
+# This has been folded into AC_PROG_CC.
+AU_ALIAS([AC_PROG_CC_STDC], [AC_PROG_CC])
# AC_C_BACKSLASH_A
@@ -1902,15 +1912,11 @@ fi
# options.
AC_DEFUN([AC_C_PROTOTYPES],
[AC_REQUIRE([AC_PROG_CC])dnl
-AC_MSG_CHECKING([for function prototypes])
-if test "$ac_cv_prog_cc_c89" != no; then
- AC_MSG_RESULT([yes])
+if test "$ac_prog_cc_stdc" != no; then
AC_DEFINE(PROTOTYPES, 1,
[Define to 1 if the C compiler supports function prototypes.])
AC_DEFINE(__PROTOTYPES, 1,
[Define like PROTOTYPES; this can be used by system headers.])
-else
- AC_MSG_RESULT([no])
fi
])# AC_C_PROTOTYPES
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index f9ba33d..9602949 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -505,36 +505,38 @@ AC_DEFUN([AC_TYPE_LONG_LONG_INT],
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
[ac_cv_type_long_long_int=yes
- if test "x${ac_cv_prog_cc_c99-no}" = xno; then
- ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
- if test $ac_cv_type_long_long_int = yes; then
- dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
- dnl If cross compiling, assume the bug is not important, since
- dnl nobody cross compiles for this platform as far as we know.
- AC_RUN_IFELSE(
- [AC_LANG_PROGRAM(
- address@hidden:@include <limits.h>
- @%:@ifndef LLONG_MAX
- @%:@ define HALF \
- (1LL << (sizeof (long long int) * CHAR_BIT - 2))
- @%:@ define LLONG_MAX (HALF - 1 + HALF)
- @%:@endif]],
- [[long long int n = 1;
- int i;
- for (i = 0; ; i++)
- {
- long long int m = n << i;
- if (m >> i != n)
- return 1;
- if (LLONG_MAX / 2 < m)
- break;
- }
- return 0;]])],
- [],
- [ac_cv_type_long_long_int=no],
- [:])
- fi
- fi])
+ case $ac_prog_cc_stdc in
+ no | c89) ;;
+ *)
+ ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
+ if test $ac_cv_type_long_long_int = yes; then
+ dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
+ dnl If cross compiling, assume the bug is not important, since
+ dnl nobody cross compiles for this platform as far as we know.
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ address@hidden:@include <limits.h>
+ @%:@ifndef LLONG_MAX
+ @%:@ define HALF \
+ (1LL << (sizeof (long long int) * CHAR_BIT - 2))
+ @%:@ define LLONG_MAX (HALF - 1 + HALF)
+ @%:@endif]],
+ [[long long int n = 1;
+ int i;
+ for (i = 0; ; i++)
+ {
+ long long int m = n << i;
+ if (m >> i != n)
+ return 1;
+ if (LLONG_MAX / 2 < m)
+ break;
+ }
+ return 0;]])],
+ [],
+ [ac_cv_type_long_long_int=no],
+ [:])
+ fi;;
+ esac])
if test $ac_cv_type_long_long_int = yes; then
AC_DEFINE([HAVE_LONG_LONG_INT], [1],
[Define to 1 if the system has the type `long long int'.])
@@ -549,12 +551,14 @@ AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
AC_CACHE_CHECK([for unsigned long long int],
[ac_cv_type_unsigned_long_long_int],
[ac_cv_type_unsigned_long_long_int=yes
- if test "x${ac_cv_prog_cc_c99-no}" = xno; then
- AC_LINK_IFELSE(
- [_AC_TYPE_LONG_LONG_SNIPPET],
- [],
- [ac_cv_type_unsigned_long_long_int=no])
- fi])
+ case $ac_prog_cc_stdc in
+ no | c89) ;;
+ *)
+ AC_LINK_IFELSE(
+ [_AC_TYPE_LONG_LONG_SNIPPET],
+ [],
+ [ac_cv_type_unsigned_long_long_int=no]);;
+ esac])
if test $ac_cv_type_unsigned_long_long_int = yes; then
AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
[Define to 1 if the system has the type `unsigned long long int'.])
--
1.7.11.4
- AC_PROG_CC_* shouldn't append multiple options, Adrian Bunk, 2012/09/20
- Re: AC_PROG_CC_* shouldn't append multiple options,
Paul Eggert <=
- Re: AC_PROG_CC_* shouldn't append multiple options, Adrian Bunk, 2012/09/20
- Re: AC_PROG_CC_* shouldn't append multiple options, Paul Eggert, 2012/09/21
- Re: AC_PROG_CC_* shouldn't append multiple options, Andrew W. Nosenko, 2012/09/21
- Re: AC_PROG_CC_* shouldn't append multiple options, Adrian Bunk, 2012/09/21
- Re: AC_PROG_CC_* shouldn't append multiple options, Andrew W. Nosenko, 2012/09/21
- Re: AC_PROG_CC_* shouldn't append multiple options, Adrian Bunk, 2012/09/21
- Re: AC_PROG_CC_* shouldn't append multiple options, Andrew W. Nosenko, 2012/09/21
- Re: AC_PROG_CC_* shouldn't append multiple options, Adrian Bunk, 2012/09/23
- Re: AC_PROG_CC_* shouldn't append multiple options, Andrew W. Nosenko, 2012/09/23
- Re: AC_PROG_CC_* shouldn't append multiple options, Adrian Bunk, 2012/09/21