summaryrefslogtreecommitdiff
path: root/autoconf
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-01-14 05:02:38 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-01-14 05:02:38 +0000
commit7ba06ede596d5638282ddc7a4fd278af85354ee4 (patch)
tree9a0596d33e252b3a08eef13013c4f138376823b5 /autoconf
parent3c733ea0649665b81947de596d410a5c4f42f5f4 (diff)
downloadllvm-7ba06ede596d5638282ddc7a4fd278af85354ee4.tar.gz
llvm-7ba06ede596d5638282ddc7a4fd278af85354ee4.tar.bz2
llvm-7ba06ede596d5638282ddc7a4fd278af85354ee4.tar.xz
Add checks to configure for sufficiently modern host compilers. This
requires Clang 3.1 or GCC 4.7. If the compiler isn't Clang or GCC, we don't try to do any sanity checking, but this give us at least a reasonable baseline of modern compilers. Also, I'm not claiming that this is the best way to do compiler version tests. I'm happy for anyone to suggest better ways of doing this test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199182 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'autoconf')
-rw-r--r--autoconf/configure.ac69
1 files changed, 69 insertions, 0 deletions
diff --git a/autoconf/configure.ac b/autoconf/configure.ac
index 435188e275..89fd237de5 100644
--- a/autoconf/configure.ac
+++ b/autoconf/configure.ac
@@ -96,6 +96,75 @@ if test "$CXX" = "clang++" ; then
AC_LANG_POP([C++])
fi
+dnl Set up variables that track whether the host compiler is GCC or Clang where
+dnl we can effectively sanity check them. We don't try to sanity check all the
+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
+ ]])],
+ llvm_cv_cxx_compiler=clang,
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! __GNUC__
+ #error
+ #endif
+ ]])],
+ llvm_cv_cxx_compiler=gcc, [])])
+AC_LANG_POP([C++])
+AC_MSG_RESULT([${llvm_cv_cxx_compiler}])
+
+dnl Check both GCC and Clang for sufficiently modern versions. These checks can
+dnl be bypassed by passing a flag if necessary on a platform.
+AC_ARG_ENABLE(compiler-version-checks,
+ AS_HELP_STRING([--enable-compiler-version-checks],
+ [Check the version of the host compiler (default is YES)]),,
+ enableval=default)
+case "$enableval" in
+ no)
+ ;;
+ yes|default)
+ AC_LANG_PUSH([C++])
+ case "$llvm_cv_cxx_compiler" in
+ clang)
+ AC_MSG_CHECKING([whether Clang is new enough])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1)
+#error This version of Clang is too old to build LLVM
+#endif
+]])],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_RESULT([no])
+ AC_MSG_ERROR([
+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.])])
+ ;;
+ gcc)
+ AC_MSG_CHECKING([whether GCC is new enough])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
+#error This version of GCC is too old to build LLVM
+#endif
+]])],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_RESULT([no])
+ AC_MSG_ERROR([
+The selected GCC C++ compiler is not new enough to build LLVM. Please upgrade
+to GCC 4.7. You may pass --disable-compiler-version-checks to configure to
+bypass these sanity checks.])])
+ ;;
+ unknown)
+ ;;
+ esac
+ AC_LANG_POP([C++])
+ ;;
+ *)
+ AC_MSG_ERROR([Invalid setting for --enable-compiler-version-checks. Use "yes" or "no"])
+ ;;
+esac
+
dnl Configure all of the projects present in our source tree. While we could
dnl just AC_CONFIG_SUBDIRS on the set of directories in projects that have a
dnl configure script, that usage of the AC_CONFIG_SUBDIRS macro is deprecated.