[cmake-developers] [PATCH] Features: Only enable C11 support on GCC >= 4.9.

Raphael Kubo da Costa rakuco at FreeBSD.org
Mon Sep 14 13:53:00 EDT 2015


Stephen Kelly <steveire at gmail.com> writes:

> Raphael Kubo da Costa wrote:
>
>> Adjust the GCC feature detection code to only consider C11 support to
>> exist on GCC >= 4.9.
>
> If you do that you must remove the definition of
> CMAKE_CXX11_STANDARD_COMPILE_OPTION for GNU < 4.8.1 too.
[...]
> sys/cdefs.h requires that if you use -std=c11, your compiler must have the
> c_thread_local feature. Therefore, you must not use -std=c11 with GNU < 4.9.
[...]
> Of course, the actual bug is in sys/cdefs.h as comment #2 in
>  https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203066
> describes.

I don't think comment #2 acknowledges there's a bug in cdefs.h; I see it
as more of an acknowledgment that adding an additional check there would
help work around/solve the issue.

> The __STDC_VERSION__ macro on its own (just like the __cplusplus macro on
> its own) is not suitable for feature testing. You must check the compiler
> vendor and version (or use SD-6 for C++).
[...]
> So, in summary, there is no bug in CMake, but either your package needs to
> change (to add CMake_NO_C_STANDARD=TRUE), or sys/cdefs.h needs to change, or
> both.

I see your point, and building with CMake_NO_C_STANDARD=TRUE or
CMAKE_C_STANDARD=99 is definitely an option. I wouldn't count on cdefs.h
being changed, and even if it was it wouldn't solve the issue on
existing systems.

Especially if you take into account the
CMAKE_CXX11_STANDARD_COMPILE_OPTION argument, one could argue that this
is about choosing how strict CMake should be when determining whether a
compiler implements a standard: enabling C++11 support only with GCC 4.8
looks limiting and leaves out all the cases where it actually works fine
with earlier versions. Is this patch too broad for C11 and GCC, or is it
different from the C++11 case? It sounded like Brad was in favor of the
former, whereas you'd like the change not to be merged.

I am fine with just changing the way CMake is packaged on FreeBSD, but
it still leaves it broken with third-party software (even outside
FreeBSD in case they use an older GCC and _Thread_local) like you
mentioned.



More information about the cmake-developers mailing list