llvm.org GIT mirror llvm / 7ba06ed
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 Chandler Carruth 6 years ago
2 changed file(s) with 401 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
9494 ])
9595 AC_LANG_POP([C++])
9696 fi
97
98 dnl Set up variables that track whether the host compiler is GCC or Clang where
99 dnl we can effectively sanity check them. We don't try to sanity check all the
100 dnl other possible compilers.
101 AC_MSG_CHECKING([whether GCC or Clang is our host compiler])
102 AC_LANG_PUSH([C++])
103 llvm_cv_cxx_compiler=unknown
104 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! __clang__
105 #error
106 #endif
107 ]])],
108 llvm_cv_cxx_compiler=clang,
109 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! __GNUC__
110 #error
111 #endif
112 ]])],
113 llvm_cv_cxx_compiler=gcc, [])])
114 AC_LANG_POP([C++])
115 AC_MSG_RESULT([${llvm_cv_cxx_compiler}])
116
117 dnl Check both GCC and Clang for sufficiently modern versions. These checks can
118 dnl be bypassed by passing a flag if necessary on a platform.
119 AC_ARG_ENABLE(compiler-version-checks,
120 AS_HELP_STRING([--enable-compiler-version-checks],
121 [Check the version of the host compiler (default is YES)]),,
122 enableval=default)
123 case "$enableval" in
124 no)
125 ;;
126 yes|default)
127 AC_LANG_PUSH([C++])
128 case "$llvm_cv_cxx_compiler" in
129 clang)
130 AC_MSG_CHECKING([whether Clang is new enough])
131 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
132 #if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1)
133 #error This version of Clang is too old to build LLVM
134 #endif
135 ]])],
136 [AC_MSG_RESULT([yes])],
137 [AC_MSG_RESULT([no])
138 AC_MSG_ERROR([
139 The selected Clang compiler is not new enough to build LLVM. Please upgrade to
140 Clang 3.1. You may pass --disable-compiler-version-checks to configure to
141 bypass these sanity checks.])])
142 ;;
143 gcc)
144 AC_MSG_CHECKING([whether GCC is new enough])
145 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
146 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
147 #error This version of GCC is too old to build LLVM
148 #endif
149 ]])],
150 [AC_MSG_RESULT([yes])],
151 [AC_MSG_RESULT([no])
152 AC_MSG_ERROR([
153 The selected GCC C++ compiler is not new enough to build LLVM. Please upgrade
154 to GCC 4.7. You may pass --disable-compiler-version-checks to configure to
155 bypass these sanity checks.])])
156 ;;
157 unknown)
158 ;;
159 esac
160 AC_LANG_POP([C++])
161 ;;
162 *)
163 AC_MSG_ERROR([Invalid setting for --enable-compiler-version-checks. Use "yes" or "no"])
164 ;;
165 esac
97166
98167 dnl Configure all of the projects present in our source tree. While we could
99168 dnl just AC_CONFIG_SUBDIRS on the set of directories in projects that have a
13951395 Optional Features:
13961396 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
13971397 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
1398 --enable-compiler-version-checks
1399 Check the version of the host compiler (default is
1400 YES)
13981401 --enable-polly Use polly if available (default is YES)
13991402 --enable-libcpp Use libc++ if available (default is NO)
14001403 --enable-cxx11 Use c++11 if available (default is NO)
35733576 ac_compiler_gnu=$ac_cv_c_compiler_gnu
35743577
35753578 fi
3579
3580 { echo "$as_me:$LINENO: checking whether GCC or Clang is our host compiler" >&5
3581 echo $ECHO_N "checking whether GCC or Clang is our host compiler... $ECHO_C" >&6; }
3582 ac_ext=cpp
3583 ac_cpp='$CXXCPP $CPPFLAGS'
3584 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
3585 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3586 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
3587
3588 llvm_cv_cxx_compiler=unknown
3589 cat >conftest.$ac_ext <<_ACEOF
3590 /* confdefs.h. */
3591 _ACEOF
3592 cat confdefs.h >>conftest.$ac_ext
3593 cat >>conftest.$ac_ext <<_ACEOF
3594 /* end confdefs.h. */
3595 #if ! __clang__
3596 #error
3597 #endif
3598
3599 int
3600 main ()
3601 {
3602
3603 ;
3604 return 0;
3605 }
3606 _ACEOF
3607 rm -f conftest.$ac_objext
3608 if { (ac_try="$ac_compile"
3609 case "(($ac_try" in
3610 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3611 *) ac_try_echo=$ac_try;;
3612 esac
3613 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3614 (eval "$ac_compile") 2>conftest.er1
3615 ac_status=$?
3616 grep -v '^ *+' conftest.er1 >conftest.err
3617 rm -f conftest.er1
3618 cat conftest.err >&5
3619 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3620 (exit $ac_status); } &&
3621 { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
3622 { (case "(($ac_try" in
3623 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3624 *) ac_try_echo=$ac_try;;
3625 esac
3626 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3627 (eval "$ac_try") 2>&5
3628 ac_status=$?
3629 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3630 (exit $ac_status); }; } &&
3631 { ac_try='test -s conftest.$ac_objext'
3632 { (case "(($ac_try" in
3633 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3634 *) ac_try_echo=$ac_try;;
3635 esac
3636 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3637 (eval "$ac_try") 2>&5
3638 ac_status=$?
3639 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3640 (exit $ac_status); }; }; then
3641 llvm_cv_cxx_compiler=clang
3642 else
3643 echo "$as_me: failed program was:" >&5
3644 sed 's/^/| /' conftest.$ac_ext >&5
3645
3646 cat >conftest.$ac_ext <<_ACEOF
3647 /* confdefs.h. */
3648 _ACEOF
3649 cat confdefs.h >>conftest.$ac_ext
3650 cat >>conftest.$ac_ext <<_ACEOF
3651 /* end confdefs.h. */
3652 #if ! __GNUC__
3653 #error
3654 #endif
3655
3656 int
3657 main ()
3658 {
3659
3660 ;
3661 return 0;
3662 }
3663 _ACEOF
3664 rm -f conftest.$ac_objext
3665 if { (ac_try="$ac_compile"
3666 case "(($ac_try" in
3667 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3668 *) ac_try_echo=$ac_try;;
3669 esac
3670 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3671 (eval "$ac_compile") 2>conftest.er1
3672 ac_status=$?
3673 grep -v '^ *+' conftest.er1 >conftest.err
3674 rm -f conftest.er1
3675 cat conftest.err >&5
3676 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3677 (exit $ac_status); } &&
3678 { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
3679 { (case "(($ac_try" in
3680 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3681 *) ac_try_echo=$ac_try;;
3682 esac
3683 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3684 (eval "$ac_try") 2>&5
3685 ac_status=$?
3686 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3687 (exit $ac_status); }; } &&
3688 { ac_try='test -s conftest.$ac_objext'
3689 { (case "(($ac_try" in
3690 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3691 *) ac_try_echo=$ac_try;;
3692 esac
3693 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3694 (eval "$ac_try") 2>&5
3695 ac_status=$?
3696 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3697 (exit $ac_status); }; }; then
3698 llvm_cv_cxx_compiler=gcc
3699 else
3700 echo "$as_me: failed program was:" >&5
3701 sed 's/^/| /' conftest.$ac_ext >&5
3702
3703
3704 fi
3705
3706 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3707 fi
3708
3709 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3710 ac_ext=c
3711 ac_cpp='$CPP $CPPFLAGS'
3712 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
3713 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3714 ac_compiler_gnu=$ac_cv_c_compiler_gnu
3715
3716 { echo "$as_me:$LINENO: result: ${llvm_cv_cxx_compiler}" >&5
3717 echo "${ECHO_T}${llvm_cv_cxx_compiler}" >&6; }
3718
3719 # Check whether --enable-compiler-version-checks was given.
3720 if test "${enable_compiler_version_checks+set}" = set; then
3721 enableval=$enable_compiler_version_checks;
3722 else
3723 enableval=default
3724 fi
3725
3726 case "$enableval" in
3727 no)
3728 ;;
3729 yes|default)
3730 ac_ext=cpp
3731 ac_cpp='$CXXCPP $CPPFLAGS'
3732 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
3733 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3734 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
3735
3736 case "$llvm_cv_cxx_compiler" in
3737 clang)
3738 { echo "$as_me:$LINENO: checking whether Clang is new enough" >&5
3739 echo $ECHO_N "checking whether Clang is new enough... $ECHO_C" >&6; }
3740 cat >conftest.$ac_ext <<_ACEOF
3741 /* confdefs.h. */
3742 _ACEOF
3743 cat confdefs.h >>conftest.$ac_ext
3744 cat >>conftest.$ac_ext <<_ACEOF
3745 /* end confdefs.h. */
3746
3747 #if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1)
3748 #error This version of Clang is too old to build LLVM
3749 #endif
3750
3751 int
3752 main ()
3753 {
3754
3755 ;
3756 return 0;
3757 }
3758 _ACEOF
3759 rm -f conftest.$ac_objext
3760 if { (ac_try="$ac_compile"
3761 case "(($ac_try" in
3762 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3763 *) ac_try_echo=$ac_try;;
3764 esac
3765 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3766 (eval "$ac_compile") 2>conftest.er1
3767 ac_status=$?
3768 grep -v '^ *+' conftest.er1 >conftest.err
3769 rm -f conftest.er1
3770 cat conftest.err >&5
3771 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3772 (exit $ac_status); } &&
3773 { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
3774 { (case "(($ac_try" in
3775 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3776 *) ac_try_echo=$ac_try;;
3777 esac
3778 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3779 (eval "$ac_try") 2>&5
3780 ac_status=$?
3781 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3782 (exit $ac_status); }; } &&
3783 { ac_try='test -s conftest.$ac_objext'
3784 { (case "(($ac_try" in
3785 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3786 *) ac_try_echo=$ac_try;;
3787 esac
3788 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3789 (eval "$ac_try") 2>&5
3790 ac_status=$?
3791 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3792 (exit $ac_status); }; }; then
3793 { echo "$as_me:$LINENO: result: yes" >&5
3794 echo "${ECHO_T}yes" >&6; }
3795 else
3796 echo "$as_me: failed program was:" >&5
3797 sed 's/^/| /' conftest.$ac_ext >&5
3798
3799 { echo "$as_me:$LINENO: result: no" >&5
3800 echo "${ECHO_T}no" >&6; }
3801 { { echo "$as_me:$LINENO: error:
3802 The selected Clang compiler is not new enough to build LLVM. Please upgrade to
3803 Clang 3.1. You may pass --disable-compiler-version-checks to configure to
3804 bypass these sanity checks." >&5
3805 echo "$as_me: error:
3806 The selected Clang compiler is not new enough to build LLVM. Please upgrade to
3807 Clang 3.1. You may pass --disable-compiler-version-checks to configure to
3808 bypass these sanity checks." >&2;}
3809 { (exit 1); exit 1; }; }
3810 fi
3811
3812 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3813 ;;
3814 gcc)
3815 { echo "$as_me:$LINENO: checking whether GCC is new enough" >&5
3816 echo $ECHO_N "checking whether GCC is new enough... $ECHO_C" >&6; }
3817 cat >conftest.$ac_ext <<_ACEOF
3818 /* confdefs.h. */
3819 _ACEOF
3820 cat confdefs.h >>conftest.$ac_ext
3821 cat >>conftest.$ac_ext <<_ACEOF
3822 /* end confdefs.h. */
3823
3824 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
3825 #error This version of GCC is too old to build LLVM
3826 #endif
3827
3828 int
3829 main ()
3830 {
3831
3832 ;
3833 return 0;
3834 }
3835 _ACEOF
3836 rm -f conftest.$ac_objext
3837 if { (ac_try="$ac_compile"
3838 case "(($ac_try" in
3839 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3840 *) ac_try_echo=$ac_try;;
3841 esac
3842 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3843 (eval "$ac_compile") 2>conftest.er1
3844 ac_status=$?
3845 grep -v '^ *+' conftest.er1 >conftest.err
3846 rm -f conftest.er1
3847 cat conftest.err >&5
3848 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3849 (exit $ac_status); } &&
3850 { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
3851 { (case "(($ac_try" in
3852 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3853 *) ac_try_echo=$ac_try;;
3854 esac
3855 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3856 (eval "$ac_try") 2>&5
3857 ac_status=$?
3858 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3859 (exit $ac_status); }; } &&
3860 { ac_try='test -s conftest.$ac_objext'
3861 { (case "(($ac_try" in
3862 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3863 *) ac_try_echo=$ac_try;;
3864 esac
3865 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3866 (eval "$ac_try") 2>&5
3867 ac_status=$?
3868 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3869 (exit $ac_status); }; }; then
3870 { echo "$as_me:$LINENO: result: yes" >&5
3871 echo "${ECHO_T}yes" >&6; }
3872 else
3873 echo "$as_me: failed program was:" >&5
3874 sed 's/^/| /' conftest.$ac_ext >&5
3875
3876 { echo "$as_me:$LINENO: result: no" >&5
3877 echo "${ECHO_T}no" >&6; }
3878 { { echo "$as_me:$LINENO: error:
3879 The selected GCC C++ compiler is not new enough to build LLVM. Please upgrade
3880 to GCC 4.7. You may pass --disable-compiler-version-checks to configure to
3881 bypass these sanity checks." >&5
3882 echo "$as_me: error:
3883 The selected GCC C++ compiler is not new enough to build LLVM. Please upgrade
3884 to GCC 4.7. You may pass --disable-compiler-version-checks to configure to
3885 bypass these sanity checks." >&2;}
3886 { (exit 1); exit 1; }; }
3887 fi
3888
3889 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3890 ;;
3891 unknown)
3892 ;;
3893 esac
3894 ac_ext=c
3895 ac_cpp='$CPP $CPPFLAGS'
3896 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
3897 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3898 ac_compiler_gnu=$ac_cv_c_compiler_gnu
3899
3900 ;;
3901 *)
3902 { { echo "$as_me:$LINENO: error: Invalid setting for --enable-compiler-version-checks. Use \"yes\" or \"no\"" >&5
3903 echo "$as_me: error: Invalid setting for --enable-compiler-version-checks. Use \"yes\" or \"no\"" >&2;}
3904 { (exit 1); exit 1; }; }
3905 ;;
3906 esac
35763907
35773908
35783909
1027710608 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1027810609 lt_status=$lt_dlunknown
1027910610 cat > conftest.$ac_ext <
10280 #line 10281 "configure"
10611 #line 10612 "configure"
1028110612 #include "confdefs.h"
1028210613
1028310614 #if HAVE_DLFCN_H