[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11
From: |
Paul Eggert |
Subject: |
Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11 |
Date: |
Fri, 28 Sep 2012 11:22:07 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 |
On 09/28/2012 05:34 AM, Adrian Bunk wrote:
> I call it a bug that gnu99 passes the
> current C11 test.
Much of the problem here is that the documentation is
not explaining the intent clearly enough. I pushed
the following patch to try to help with this. This also should
address the glitch with IBM XL C V12.1 that you noted earlier.
>From bccf4b98eebc09f4f8c77bfe4bafef41cc05e540 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Fri, 28 Sep 2012 10:44:16 -0700
Subject: [PATCH] AC_PROG_CC: clarify documentation, encourage
-qlanglvl=extc1x
* doc/autoconf.texi (C Compiler): Document the intent of AC_PROG_CC
better. It's not meant to check for strict conformance, only to
get the latest version with extensions.
(Running the Preprocessor, Present But Cannot Be Compiled):
Document new diagnostic wording.
* lib/autoconf/c.m4 (_AC_C_STD_TRY): Change diagnostic wording from
"checking for gcc option to accept ISO C11" to
"checkint for gcc option to enable C11 features", as this better
reflects what is actually happening.
(_AC_PROG_CC_C99): Put -qlanglvl=extc1x here ...
(_AC_PROG_CC_C11): ... rather than here, as it doesn't pass the C11
test with IBM XL C V12.1, and the point is to enable features not to
test for strict conformance.
---
doc/autoconf.texi | 19 ++++++++++---------
lib/autoconf/c.m4 | 18 +++++++++++++-----
2 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 08082aa..e0666d4 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -7247,17 +7247,18 @@ this:
AC_PROG_CC([gcc cl cc])
@end example
-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.
+If necessary, add an option to output variable @code{CC} to enable
+support for ISO Standard C features with extensions. Prefer the newest
+C standard that is supported. Currently the newest standard is ISO C11,
+with ISO C99 and ANSI C89 (ISO C90) being the older versions.
After calling this macro you can check whether the C compiler has been
set to accept Standard C; if not, the shell variable
@code{ac_cv_prog_cc_stdc} is set to @samp{no}.
When attempting to add compiler options, prefer extended functionality
-modes over strict conformance modes. Test for C11 support by checking
+to strict conformance: the goal is to enable whatever standard features
+that are available, not to check for full conformance to the standard or
+to prohibit incompatible extensions. Test for C11 support by checking
for @code{_Alignas}, @code{_Alignof}, @code{_Noreturn},
@code{_Static_assert}, UTF-8 string literals, duplicate @code{typedef}s,
and anonymous structures and unions. Test for C99 support by checking
@@ -9289,7 +9290,7 @@ checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
-checking for gcc option to accept ISO C11... -std=gnu11
+checking for gcc option to enable C11 features... -std=gnu11
checking how to run the C preprocessor... gcc -std=gnu11 -E
OK
@end example
@@ -25923,7 +25924,7 @@ checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
-checking for gcc option to accept ISO C11... -std=gnu11
+checking for gcc option to enable C11 features... -std=gnu11
checking how to run the C preprocessor... gcc -std=gnu11 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
@@ -25972,7 +25973,7 @@ checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
-checking for gcc option to accept ISO C11... -std=gnu11
+checking for gcc option to enable C11 features... -std=gnu11
checking for number.h... yes
checking for pi.h... yes
@end example
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 0309416..ad40527 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -1164,7 +1164,7 @@ dnl SVR4 -Xc -D__EXTENSIONS__
# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,
# else ACTION-IF-UNAVAILABLE.
AC_DEFUN([_AC_C_STD_TRY],
-[AC_MSG_CHECKING([for $CC option to accept ISO ]m4_translit($1, [c], [C]))
+[AC_MSG_CHECKING([for $CC option to enable ]m4_translit($1, [c], [C])[
features])
AC_CACHE_VAL(ac_cv_prog_cc_$1,
[ac_cv_prog_cc_$1=no
ac_save_CC=$CC
@@ -1347,7 +1347,9 @@ AC_DEFUN([_AC_PROG_CC_C99],
[_AC_C_C99_TEST_BODY],
dnl Try
dnl GCC -std=gnu99 (unused restrictive modes: -std=c99
-std=iso9899:1999)
-dnl IBM XL C -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99)
+dnl IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test)
+dnl IBM XL C -qlanglvl=extc99
+dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdc99)
dnl HP cc -AC99
dnl Intel ICC -std=c99, -c99 (deprecated)
dnl IRIX -c99
@@ -1364,7 +1366,7 @@ dnl good enough. For more, please see the
thread starting at:
dnl http://lists.gnu.org/archive/html/autoconf/2010-12/msg00059.html
dnl Tru64 -c99
dnl with extended modes being tried first.
-[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99]], [$1],
[$2])[]dnl
+[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x
-qlanglvl=extc99]], [$1], [$2])[]dnl
])# _AC_PROG_CC_C99
@@ -1432,9 +1434,15 @@ struct anonymous
]],
dnl Try
dnl GCC -std=gnu11 (unused restrictive mode: -std=c11)
-dnl IBM XL C -qlanglvl=extc1x (no extc11 or (unused) stdc11 in V12.1)
dnl with extended modes being tried first.
-[[-std=gnu11 -qlanglvl=extc1x]], [$1], [$2])[]dnl
+dnl
+dnl Do not try -qlanglvl=extc1x, because IBM XL C V12.1 (the latest version as
+dnl of September 2012) does not pass the C11 test. For now, try extc1x when
+dnl compiling the C99 test instead, since it enables _Static_assert and
+dnl _Noreturn, which is a win. If -qlanglvl=extc11 or -qlanglvl=extc1x passes
+dnl the C11 test in some future version of IBM XL C, we'll add it here,
+dnl preferably extc11.
+[[-std=gnu11]], [$1], [$2])[]dnl
])# _AC_PROG_CC_C11
--
1.7.11.4
- Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11, (continued)
- Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11, Paul Eggert, 2012/09/26
- Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11, Adrian Bunk, 2012/09/27
- Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11, Paul Eggert, 2012/09/27
- Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11, Adrian Bunk, 2012/09/27
- Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11, Paul Eggert, 2012/09/27
- Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11, Adrian Bunk, 2012/09/28
- Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11, Andrew W. Nosenko, 2012/09/28
- Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11, Adrian Bunk, 2012/09/28
- Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11, Andrew W. Nosenko, 2012/09/28
- Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11, Adrian Bunk, 2012/09/28
- Re: bug: "gcc -std=gnu99" passes AC_PROG_CC_C11,
Paul Eggert <=