Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 7ba06ed

Browse files
committed
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
1 parent 3c733ea commit 7ba06ed

File tree

2 files changed

+401
-1
lines changed

2 files changed

+401
-1
lines changed

autoconf/configure.ac

+69
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,75 @@ if test "$CXX" = "clang++" ; then
9696
AC_LANG_POP([C++])
9797
fi
9898

99+
dnl Set up variables that track whether the host compiler is GCC or Clang where
100+
dnl we can effectively sanity check them. We don't try to sanity check all the
101+
dnl other possible compilers.
102+
AC_MSG_CHECKING([whether GCC or Clang is our host compiler])
103+
AC_LANG_PUSH([C++])
104+
llvm_cv_cxx_compiler=unknown
105+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! __clang__
106+
#error
107+
#endif
108+
]])],
109+
llvm_cv_cxx_compiler=clang,
110+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! __GNUC__
111+
#error
112+
#endif
113+
]])],
114+
llvm_cv_cxx_compiler=gcc, [])])
115+
AC_LANG_POP([C++])
116+
AC_MSG_RESULT([${llvm_cv_cxx_compiler}])
117+
118+
dnl Check both GCC and Clang for sufficiently modern versions. These checks can
119+
dnl be bypassed by passing a flag if necessary on a platform.
120+
AC_ARG_ENABLE(compiler-version-checks,
121+
AS_HELP_STRING([--enable-compiler-version-checks],
122+
[Check the version of the host compiler (default is YES)]),,
123+
enableval=default)
124+
case "$enableval" in
125+
no)
126+
;;
127+
yes|default)
128+
AC_LANG_PUSH([C++])
129+
case "$llvm_cv_cxx_compiler" in
130+
clang)
131+
AC_MSG_CHECKING([whether Clang is new enough])
132+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
133+
#if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1)
134+
#error This version of Clang is too old to build LLVM
135+
#endif
136+
]])],
137+
[AC_MSG_RESULT([yes])],
138+
[AC_MSG_RESULT([no])
139+
AC_MSG_ERROR([
140+
The selected Clang compiler is not new enough to build LLVM. Please upgrade to
141+
Clang 3.1. You may pass --disable-compiler-version-checks to configure to
142+
bypass these sanity checks.])])
143+
;;
144+
gcc)
145+
AC_MSG_CHECKING([whether GCC is new enough])
146+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
147+
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
148+
#error This version of GCC is too old to build LLVM
149+
#endif
150+
]])],
151+
[AC_MSG_RESULT([yes])],
152+
[AC_MSG_RESULT([no])
153+
AC_MSG_ERROR([
154+
The selected GCC C++ compiler is not new enough to build LLVM. Please upgrade
155+
to GCC 4.7. You may pass --disable-compiler-version-checks to configure to
156+
bypass these sanity checks.])])
157+
;;
158+
unknown)
159+
;;
160+
esac
161+
AC_LANG_POP([C++])
162+
;;
163+
*)
164+
AC_MSG_ERROR([Invalid setting for --enable-compiler-version-checks. Use "yes" or "no"])
165+
;;
166+
esac
167+
99168
dnl Configure all of the projects present in our source tree. While we could
100169
dnl just AC_CONFIG_SUBDIRS on the set of directories in projects that have a
101170
dnl configure script, that usage of the AC_CONFIG_SUBDIRS macro is deprecated.

0 commit comments

Comments
 (0)