[PATCH] D58682: Add secondary libstdc++ 4.8 and 5.1 detection mechanisms

Hubert Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 7 13:31:43 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL355638: Add secondary libstdc++ 4.8 and 5.1 detection mechanisms (authored by hubert.reinterpretcast, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58682/new/

https://reviews.llvm.org/D58682

Files:
  llvm/trunk/cmake/modules/CheckCompilerVersion.cmake


Index: llvm/trunk/cmake/modules/CheckCompilerVersion.cmake
===================================================================
--- llvm/trunk/cmake/modules/CheckCompilerVersion.cmake
+++ llvm/trunk/cmake/modules/CheckCompilerVersion.cmake
@@ -58,6 +58,8 @@
     set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
     set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
     set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++0x")
+    # Test for libstdc++ version of at least 4.8 by checking for _ZNKSt17bad_function_call4whatEv.
+    # Note: We should check _GLIBCXX_RELEASE when possible (i.e., for GCC 7.1 and up).
     check_cxx_source_compiles("
 #include <iosfwd>
 #if defined(__GLIBCXX__)
@@ -65,12 +67,20 @@
 #error Unsupported libstdc++ version
 #endif
 #endif
-int main() { return 0; }
+#if defined(__GLIBCXX__)
+extern const char _ZNKSt17bad_function_call4whatEv[];
+const char *chk = _ZNKSt17bad_function_call4whatEv;
+#else
+const char *chk = \"\";
+#endif
+int main() { ++chk; return 0; }
 "
       LLVM_LIBSTDCXX_MIN)
     if(NOT LLVM_LIBSTDCXX_MIN)
       message(FATAL_ERROR "libstdc++ version must be at least ${GCC_MIN}.")
     endif()
+    # Test for libstdc++ version of at least 5.1 by checking for std::iostream_category().
+    # Note: We should check _GLIBCXX_RELEASE when possible (i.e., for GCC 7.1 and up).
     check_cxx_source_compiles("
 #include <iosfwd>
 #if defined(__GLIBCXX__)
@@ -78,6 +88,10 @@
 #error Unsupported libstdc++ version
 #endif
 #endif
+#if defined(__GLIBCXX__)
+#include <ios>
+void foo(void) { (void) std::iostream_category(); }
+#endif
 int main() { return 0; }
 "
       LLVM_LIBSTDCXX_SOFT_ERROR)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58682.189778.patch
Type: text/x-patch
Size: 1673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190307/ce62420d/attachment.bin>


More information about the llvm-commits mailing list