summaryrefslogtreecommitdiff
path: root/autoconf
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-01-15 10:31:15 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-01-15 10:31:15 +0000
commit9c62b5eabb41d41023815df01d07bda5abbd8c4c (patch)
tree4d71e1f11d53cf825689eb0572445be95673a749 /autoconf
parentf62176f04759d1841e97064297337645cf536423 (diff)
downloadllvm-9c62b5eabb41d41023815df01d07bda5abbd8c4c.tar.gz
llvm-9c62b5eabb41d41023815df01d07bda5abbd8c4c.tar.bz2
llvm-9c62b5eabb41d41023815df01d07bda5abbd8c4c.tar.xz
Add a check to configure that the libstdc++ selected by Clang isn't
libstdc++v4.6. This is quite hard to test directly, so we test for it by checking a known missing feature in that version that was added in v4.7. This should prevent users from upgrading Clang but not GCC and hosting with a too-old GCC's libstdc++ and getting strange and hard to debug errors when we switch to C++11 by default. Also, switch several of the macros I introduced to use AC_LANG_SOURCE rather than AC_LANG_PROGRAM as we don't need configure's help writing our main function (and we don't need such a function at all for most of the tests). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199313 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'autoconf')
-rw-r--r--autoconf/configure.ac44
1 files changed, 34 insertions, 10 deletions
diff --git a/autoconf/configure.ac b/autoconf/configure.ac
index 0a90de86e1..6906a7586b 100644
--- a/autoconf/configure.ac
+++ b/autoconf/configure.ac
@@ -102,15 +102,15 @@ dnl other possible compilers.
AC_MSG_CHECKING([whether GCC or Clang is our host compiler])
AC_LANG_PUSH([C++])
llvm_cv_cxx_compiler=unknown
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! __clang__
- #error
- #endif
- ]])],
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if ! __clang__
+ #error
+ #endif
+ ]])],
llvm_cv_cxx_compiler=clang,
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! __GNUC__
- #error
- #endif
- ]])],
+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if ! __GNUC__
+ #error
+ #endif
+ ]])],
llvm_cv_cxx_compiler=gcc, [])])
AC_LANG_POP([C++])
AC_MSG_RESULT([${llvm_cv_cxx_compiler}])
@@ -129,7 +129,7 @@ case "$enableval" in
case "$llvm_cv_cxx_compiler" in
clang)
AC_MSG_CHECKING([whether Clang is new enough])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1)
#error This version of Clang is too old to build LLVM
#endif
@@ -140,10 +140,34 @@ case "$enableval" in
The selected Clang compiler is not new enough to build LLVM. Please upgrade to
Clang 3.1. You may pass --disable-compiler-version-checks to configure to
bypass these sanity checks.])])
+
+ dnl Note that libstdc++4.6 is known broken for C++11 builds. The errors
+ dnl are sometimes deeply confusing though. Here we test for an obvious
+ dnl incomplete feature in 4.6's standard library that was completed in
+ dnl 4.7's.
+ AC_MSG_CHECKING([whether Clang will select a modern C++ standard library])
+ llvm_cv_old_cxxflags="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -std=c++0x"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
+#include <atomic>
+std::atomic<float> x(0.0f);
+int main() { return (float)x; }
+]])],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_RESULT([no])
+ AC_MSG_ERROR([
+We detected a missing feature in the standard C++ library that was known to be
+missing in libstdc++4.6 and implemented in libstdc++4.7. There are numerous
+C++11 problems with 4.6's library, and we don't support GCCs or libstdc++ older
+than 4.7. You will need to update your system and ensure Clang uses the newer
+standard library.
+
+If this error is incorrect or you need to force things to work, you may pass
+'--disable-compiler-version-checks' to configure to bypass this test.])])
;;
gcc)
AC_MSG_CHECKING([whether GCC is new enough])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
#error This version of GCC is too old to build LLVM
#endif