llvm.org GIT mirror llvm / 9c62b5e
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 Chandler Carruth 6 years ago
2 changed file(s) with 123 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
101101 AC_MSG_CHECKING([whether GCC or Clang is our host compiler])
102102 AC_LANG_PUSH([C++])
103103 llvm_cv_cxx_compiler=unknown
104 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! __clang__
105 #error
106 #endif
107 ]])],
104 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if ! __clang__
105 #error
106 #endif
107 ]])],
108108 llvm_cv_cxx_compiler=clang,
109 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! __GNUC__
110 #error
111 #endif
112 ]])],
109 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if ! __GNUC__
110 #error
111 #endif
112 ]])],
113113 llvm_cv_cxx_compiler=gcc, [])])
114114 AC_LANG_POP([C++])
115115 AC_MSG_RESULT([${llvm_cv_cxx_compiler}])
128128 case "$llvm_cv_cxx_compiler" in
129129 clang)
130130 AC_MSG_CHECKING([whether Clang is new enough])
131 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
131 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
132132 #if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1)
133133 #error This version of Clang is too old to build LLVM
134134 #endif
139139 The selected Clang compiler is not new enough to build LLVM. Please upgrade to
140140 Clang 3.1. You may pass --disable-compiler-version-checks to configure to
141141 bypass these sanity checks.])])
142
143 dnl Note that libstdc++4.6 is known broken for C++11 builds. The errors
144 dnl are sometimes deeply confusing though. Here we test for an obvious
145 dnl incomplete feature in 4.6's standard library that was completed in
146 dnl 4.7's.
147 AC_MSG_CHECKING([whether Clang will select a modern C++ standard library])
148 llvm_cv_old_cxxflags="$CXXFLAGS"
149 CXXFLAGS="$CXXFLAGS -std=c++0x"
150 AC_LINK_IFELSE([AC_LANG_SOURCE([[
151 #include
152 std::atomic x(0.0f);
153 int main() { return (float)x; }
154 ]])],
155 [AC_MSG_RESULT([yes])],
156 [AC_MSG_RESULT([no])
157 AC_MSG_ERROR([
158 We detected a missing feature in the standard C++ library that was known to be
159 missing in libstdc++4.6 and implemented in libstdc++4.7. There are numerous
160 C++11 problems with 4.6's library, and we don't support GCCs or libstdc++ older
161 than 4.7. You will need to update your system and ensure Clang uses the newer
162 standard library.
163
164 If this error is incorrect or you need to force things to work, you may pass
165 '--disable-compiler-version-checks' to configure to bypass this test.])])
142166 ;;
143167 gcc)
144168 AC_MSG_CHECKING([whether GCC is new enough])
145 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
169 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
146170 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
147171 #error This version of GCC is too old to build LLVM
148172 #endif
35923592 cat >>conftest.$ac_ext <<_ACEOF
35933593 /* end confdefs.h. */
35943594 #if ! __clang__
3595 #error
3596 #endif
3597
3598 int
3599 main ()
3600 {
3601
3602 ;
3603 return 0;
3604 }
3595 #error
3596 #endif
3597
36053598 _ACEOF
36063599 rm -f conftest.$ac_objext
36073600 if { (ac_try="$ac_compile"
36493642 cat >>conftest.$ac_ext <<_ACEOF
36503643 /* end confdefs.h. */
36513644 #if ! __GNUC__
3652 #error
3653 #endif
3654
3655 int
3656 main ()
3657 {
3658
3659 ;
3660 return 0;
3661 }
3645 #error
3646 #endif
3647
36623648 _ACEOF
36633649 rm -f conftest.$ac_objext
36643650 if { (ac_try="$ac_compile"
37473733 #error This version of Clang is too old to build LLVM
37483734 #endif
37493735
3750 int
3751 main ()
3752 {
3753
3754 ;
3755 return 0;
3756 }
37573736 _ACEOF
37583737 rm -f conftest.$ac_objext
37593738 if { (ac_try="$ac_compile"
38093788 fi
38103789
38113790 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3791
3792 { echo "$as_me:$LINENO: checking whether Clang will select a modern C++ standard library" >&5
3793 echo $ECHO_N "checking whether Clang will select a modern C++ standard library... $ECHO_C" >&6; }
3794 llvm_cv_old_cxxflags="$CXXFLAGS"
3795 CXXFLAGS="$CXXFLAGS -std=c++0x"
3796 cat >conftest.$ac_ext <<_ACEOF
3797 /* confdefs.h. */
3798 _ACEOF
3799 cat confdefs.h >>conftest.$ac_ext
3800 cat >>conftest.$ac_ext <<_ACEOF
3801 /* end confdefs.h. */
3802
3803 #include
3804 std::atomic x(0.0f);
3805 int main() { return (float)x; }
3806
3807 _ACEOF
3808 rm -f conftest.$ac_objext conftest$ac_exeext
3809 if { (ac_try="$ac_link"
3810 case "(($ac_try" in
3811 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3812 *) ac_try_echo=$ac_try;;
3813 esac
3814 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3815 (eval "$ac_link") 2>conftest.er1
3816 ac_status=$?
3817 grep -v '^ *+' conftest.er1 >conftest.err
3818 rm -f conftest.er1
3819 cat conftest.err >&5
3820 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3821 (exit $ac_status); } &&
3822 { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
3823 { (case "(($ac_try" in
3824 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3825 *) ac_try_echo=$ac_try;;
3826 esac
3827 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3828 (eval "$ac_try") 2>&5
3829 ac_status=$?
3830 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3831 (exit $ac_status); }; } &&
3832 { ac_try='test -s conftest$ac_exeext'
3833 { (case "(($ac_try" in
3834 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3835 *) ac_try_echo=$ac_try;;
3836 esac
3837 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3838 (eval "$ac_try") 2>&5
3839 ac_status=$?
3840 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3841 (exit $ac_status); }; }; then
3842 { echo "$as_me:$LINENO: result: yes" >&5
3843 echo "${ECHO_T}yes" >&6; }
3844 else
3845 echo "$as_me: failed program was:" >&5
3846 sed 's/^/| /' conftest.$ac_ext >&5
3847
3848 { echo "$as_me:$LINENO: result: no" >&5
3849 echo "${ECHO_T}no" >&6; }
3850 { { echo "$as_me:$LINENO: error:
3851 We detected a missing feature in the standard C++ library that was known to be
3852 missing in libstdc++4.6 and implemented in libstdc++4.7. There are numerous
3853 C++11 problems with 4.6's library, and we don't support GCCs or libstdc++ older
3854 than 4.7. You will need to update your system and ensure Clang uses the newer
3855 standard library.
3856
3857 If this error is incorrect or you need to force things to work, you may pass
3858 '--disable-compiler-version-checks' to configure to bypass this test." >&5
3859 echo "$as_me: error:
3860 We detected a missing feature in the standard C++ library that was known to be
3861 missing in libstdc++4.6 and implemented in libstdc++4.7. There are numerous
3862 C++11 problems with 4.6's library, and we don't support GCCs or libstdc++ older
3863 than 4.7. You will need to update your system and ensure Clang uses the newer
3864 standard library.
3865
3866 If this error is incorrect or you need to force things to work, you may pass
3867 '--disable-compiler-version-checks' to configure to bypass this test." >&2;}
3868 { (exit 1); exit 1; }; }
3869 fi
3870
3871 rm -f core conftest.err conftest.$ac_objext \
3872 conftest$ac_exeext conftest.$ac_ext
38123873 ;;
38133874 gcc)
38143875 { echo "$as_me:$LINENO: checking whether GCC is new enough" >&5
38243885 #error This version of GCC is too old to build LLVM
38253886 #endif
38263887
3827 int
3828 main ()
3829 {
3830
3831 ;
3832 return 0;
3833 }
38343888 _ACEOF
38353889 rm -f conftest.$ac_objext
38363890 if { (ac_try="$ac_compile"
1060510659 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1060610660 lt_status=$lt_dlunknown
1060710661 cat > conftest.$ac_ext <
10608 #line 10609 "configure"
10662 #line 10663 "configure"
1060910663 #include "confdefs.h"
1061010664
1061110665 #if HAVE_DLFCN_H