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

Stephen Kelly steveire at gmail.com
Mon Sep 14 15:37:13 EDT 2015


Raphael Kubo da Costa wrote:

> 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.

I do consider it a bug :). Standards are too coarse, features of the 
compiler are what is relevant:

 http://www.kdab.com/modern-cmake-with-qt-and-boost/#compile-feature-specification

That's also the whole point of SD-6 for C++.

The problematic content of the header affects all third party code in and 
out of the ports system, using cmake or not :).

But it doesn't matter that I consider it a bug. I'm not going to fix 
sys/cdefs.h either :). I can keep my opinions to myself, and people using 
that combination of toolchain have to deal with it :). 

> 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.

Conversely, claiming GNU 4.4 supports C++11 doesn't make sense either 
(because standards are too coarse, features are what is relevant), which is 
why I consider CMAKE_CXX_STANDARD_REQUIRED to be nonsense.

So, yes, I agree with you here :).

Thanks,

Steve.




More information about the cmake-developers mailing list