From: Kefu Chai Date: Thu, 9 Nov 2017 06:35:00 +0000 (+0800) Subject: cmake: warn if libstdc++ older than 5.1.0 is used X-Git-Tag: v13.0.1~239^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1d0866af350a260a83c2e185e4f3eff1f2bb2f81;p=ceph.git cmake: warn if libstdc++ older than 5.1.0 is used __GLIBCPP__ is used before 3.4.0, and gcc 4.8.0 and up is required to build c++11 source, hence it's safe to check __GLIBCXX__. for the versioning of libstdc++, see https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning, for the magic number of 20150422ul see https://gcc.gnu.org/develop.html#timeline. for the reason why we want to have this warning, see https://github.com/ceph/ceph/pull/18755#issuecomment-342736554 . Signed-off-by: Kefu Chai --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 60e609d9d18..c4469b2041b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -166,6 +166,21 @@ else() set(C_STANDARD_REQUIRED ON) endif() +include(CheckCXXSourceCompiles) +CHECK_CXX_SOURCE_COMPILES(" +int main() { +#ifdef __GLIBCXX__ +#if __GLIBCXX__ < 20150422ul /* libstdc++ < 5.1.0 */ +#error libstdc++ < 5.1.0 does not confirm to C++11 +#endif +#endif +} +" HAVE_SANE_GLIBCXX) +if(NOT HAVE_SANE_GLIBCXX) + # libstdc++ 4.9 has O(n) list::size(), and its regex is buggy + message(WARNING "performance regression is expected due to an O(n) implementation of 'std::list::size()' in libstdc++ older than 5.1.0") +endif() + ## Handle diagnostics color if compiler supports them. CHECK_C_COMPILER_FLAG("-fdiagnostics-color=always" COMPILER_SUPPORTS_DIAGNOSTICS_COLOR)