Message ID | 20240918162127.230702-1-jason@redhat.com |
---|---|
State | New |
Headers | show |
Series | [RFC] build: update bootstrap req to C++14 | expand |
> On 18 Sep 2024, at 17:18, Jason Merrill <jason@redhat.com> wrote: > > Tested x86_64-pc-linux-gnu with 5.5.0 bootstrap compiler. Thoughts? Despite that adequate support is available in GCC-5.5/6, would it be useful to jump to a version that allows a single toolchain to bootstrap all the currently supported languages (currently we have 4.8.x for the c-family+fortran, 5 for Ada and 9 for D which is somewhat unhelpful for folks who test all supported langs). Iain > > -- 8< -- > > This implements my proposal to update our bootstrap requirement to C++14. > The big benefit of the change is the greater constexpr power, but C++14 also > added variable templates, generic lambdas, lambda init-capture, binary > literals, and numeric literal digit separators. > > I'm not sure which GCC version to mention here. C++14 was feature-complete > in GCC 5, and became the default in GCC 6. 5.5.0 builds trunk with no > trouble, but of course trunk also doesn't use any C++14 features. Looking > at bugzilla, I see only one C++14 fix (PR71630) in 5.5, and it doesn't seem > important. In 5.4, PR69995 seems potentially significant, so shall we > recommend 5.4 or later? Or just say 5.5 because people are unlikely to be > stuck on an earlier minor release? > > gcc/ChangeLog: > > * doc/install.texi (Prerequisites): Update to C++14. > > ChangeLog: > > * configure.ac: Update requirement to C++14. > * configure: Regenerate. > --- > gcc/doc/install.texi | 15 +- > configure.ac | 12 +- > configure | 832 ++++++++++++++++++++++++++++++++++++++++--- > 3 files changed, 790 insertions(+), 69 deletions(-) > > diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi > index e339d736969..87add0b6572 100644 > --- a/gcc/doc/install.texi > +++ b/gcc/doc/install.texi > @@ -222,17 +222,18 @@ described below. > > @heading Tools/packages necessary for building GCC > @table @asis > -@item ISO C++11 compiler > -Necessary to bootstrap GCC. GCC 4.8.3 or newer has sufficient > -support for used C++11 features. > +@item ISO C++14 compiler > +Necessary to bootstrap GCC. GCC 5.5 or newer has sufficient > +support for used C++14 features. > > -Versions of GCC prior to 11 also allow bootstrapping with an ISO C++98 > -compiler, and versions of GCC prior to 4.8 also allow bootstrapping with > -an ISO C89 compiler. > +Versions of GCC prior to 15 allow bootstrapping with an ISO C++11 > +compiler, versions prior to 11 allow bootstrapping with an ISO C++98 > +compiler, and versions prior to 4.8 allow bootstrapping with an ISO > +C89 compiler. > > To build all languages in a cross-compiler or other configuration where > 3-stage bootstrap is not performed, you need to start with an existing > -GCC binary (version 4.8.3 or later) because source code for language > +GCC binary (version 5.5 or later) because source code for language > frontends other than C might use GCC extensions. > > @item C standard library and headers > diff --git a/configure.ac b/configure.ac > index f61dbe64a94..91635d5368a 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -1457,16 +1457,16 @@ case "$have_compiler:$host:$target:$enable_bootstrap" in > ;; > esac > > -# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a > -# C++11 compiler can still start the bootstrap. Otherwise, if building GCC, > -# require C++11 (or higher). > +# When bootstrapping with GCC, build stage 1 in C++14 mode to ensure that a > +# C++14 compiler can still start the bootstrap. Otherwise, if building GCC, > +# require C++14 (or higher). > if test "$enable_bootstrap:$GXX" = "yes:yes"; then > - CXX="$CXX -std=c++11" > + CXX="$CXX -std=c++14" > elif test "$have_compiler" = yes; then > - AX_CXX_COMPILE_STDCXX(11) > + AX_CXX_COMPILE_STDCXX(14) > > if test "${build}" != "${host}"; then > - AX_CXX_COMPILE_STDCXX(11, [], [], [_FOR_BUILD]) > + AX_CXX_COMPILE_STDCXX(14, [], [], [_FOR_BUILD]) > fi > fi > > diff --git a/configure b/configure > index e9583f2ba0c..ab9719c6e93 100755 > --- a/configure > +++ b/configure > @@ -712,8 +712,8 @@ gmplibs > PGO_BUILD_LTO_CFLAGS > PGO_BUILD_USE_CFLAGS > PGO_BUILD_GEN_CFLAGS > -HAVE_CXX11_FOR_BUILD > -HAVE_CXX11 > +HAVE_CXX14_FOR_BUILD > +HAVE_CXX14 > do_compare > CARGO > GDC > @@ -5914,13 +5914,13 @@ $as_echo "$as_me: WARNING: trying to bootstrap a cross compiler" >&2;} > ;; > esac > > -# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a > -# C++11 compiler can still start the bootstrap. Otherwise, if building GCC, > -# require C++11 (or higher). > +# When bootstrapping with GCC, build stage 1 in C++14 mode to ensure that a > +# C++14 compiler can still start the bootstrap. Otherwise, if building GCC, > +# require C++14 (or higher). > if test "$enable_bootstrap:$GXX" = "yes:yes"; then > - CXX="$CXX -std=c++11" > + CXX="$CXX -std=c++14" > elif test "$have_compiler" = yes; then > - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true > + ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=true > ac_ext=cpp > ac_cpp='$CXXCPP $CPPFLAGS' > ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' > @@ -5928,9 +5928,9 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex > ac_compiler_gnu=$ac_cv_cxx_compiler_gnu > ac_success=no > > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 > -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } > -if ${ax_cv_cxx_compile_cxx11+:} false; then : > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features by default" >&5 > +$as_echo_n "checking whether $CXX supports C++14 features by default... " >&6; } > +if ${ax_cv_cxx_compile_cxx14+:} false; then : > $as_echo_n "(cached) " >&6 > else > cat confdefs.h - <<_ACEOF >conftest.$ac_ext > @@ -6223,26 +6223,146 @@ namespace cxx11 > > > > + > +// If the compiler admits that it is not ready for C++14, why torture it? > +// Hopefully, this will speed up the test. > + > +#ifndef __cplusplus > + > +#error "This is not a C++ compiler" > + > +#elif __cplusplus < 201402L > + > +#error "This is not a C++14 compiler" > + > +#else > + > +namespace cxx14 > +{ > + > + namespace test_polymorphic_lambdas > + { > + > + int > + test() > + { > + const auto lambda = [](auto&&... args){ > + const auto istiny = [](auto x){ > + return (sizeof(x) == 1UL) ? 1 : 0; > + }; > + const int aretiny[] = { istiny(args)... }; > + return aretiny[0]; > + }; > + return lambda(1, 1L, 1.0f, '1'); > + } > + > + } > + > + namespace test_binary_literals > + { > + > + constexpr auto ivii = 0b0000000000101010; > + static_assert(ivii == 42, "wrong value"); > + > + } > + > + namespace test_generalized_constexpr > + { > + > + template < typename CharT > > + constexpr unsigned long > + strlen_c(const CharT *const s) noexcept > + { > + auto length = 0UL; > + for (auto p = s; *p; ++p) > + ++length; > + return length; > + } > + > + static_assert(strlen_c("") == 0UL, ""); > + static_assert(strlen_c("x") == 1UL, ""); > + static_assert(strlen_c("test") == 4UL, ""); > + static_assert(strlen_c("another\0test") == 7UL, ""); > + > + } > + > + namespace test_lambda_init_capture > + { > + > + int > + test() > + { > + auto x = 0; > + const auto lambda1 = [a = x](int b){ return a + b; }; > + const auto lambda2 = [a = lambda1(x)](){ return a; }; > + return lambda2(); > + } > + > + } > + > + namespace test_digit_separators > + { > + > + constexpr auto ten_million = 100'000'000; > + static_assert(ten_million == 100000000, ""); > + > + } > + > + namespace test_return_type_deduction > + { > + > + auto f(int& x) { return x; } > + decltype(auto) g(int& x) { return x; } > + > + template < typename T1, typename T2 > > + struct is_same > + { > + static constexpr auto value = false; > + }; > + > + template < typename T > > + struct is_same<T, T> > + { > + static constexpr auto value = true; > + }; > + > + int > + test() > + { > + auto x = 0; > + static_assert(is_same<int, decltype(f(x))>::value, ""); > + static_assert(is_same<int&, decltype(g(x))>::value, ""); > + return x; > + } > + > + } > + > +} // namespace cxx14 > + > +#endif // __cplusplus >= 201402L > + > + > + > _ACEOF > if ac_fn_cxx_try_compile "$LINENO"; then : > - ax_cv_cxx_compile_cxx11=yes > + ax_cv_cxx_compile_cxx14=yes > else > - ax_cv_cxx_compile_cxx11=no > + ax_cv_cxx_compile_cxx14=no > fi > rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > fi > -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 > -$as_echo "$ax_cv_cxx_compile_cxx11" >&6; } > - if test x$ax_cv_cxx_compile_cxx11 = xyes; then > +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx14" >&5 > +$as_echo "$ax_cv_cxx_compile_cxx14" >&6; } > + if test x$ax_cv_cxx_compile_cxx14 = xyes; then > ac_success=yes > fi > > if test x$ac_success = xno; then > for alternative in ${ax_cxx_compile_alternatives}; do > switch="-std=gnu++${alternative}" > - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 > -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } > + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 > +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } > if eval \${$cachevar+:} false; then : > $as_echo_n "(cached) " >&6 > else > @@ -6538,6 +6658,126 @@ namespace cxx11 > > > > + > +// If the compiler admits that it is not ready for C++14, why torture it? > +// Hopefully, this will speed up the test. > + > +#ifndef __cplusplus > + > +#error "This is not a C++ compiler" > + > +#elif __cplusplus < 201402L > + > +#error "This is not a C++14 compiler" > + > +#else > + > +namespace cxx14 > +{ > + > + namespace test_polymorphic_lambdas > + { > + > + int > + test() > + { > + const auto lambda = [](auto&&... args){ > + const auto istiny = [](auto x){ > + return (sizeof(x) == 1UL) ? 1 : 0; > + }; > + const int aretiny[] = { istiny(args)... }; > + return aretiny[0]; > + }; > + return lambda(1, 1L, 1.0f, '1'); > + } > + > + } > + > + namespace test_binary_literals > + { > + > + constexpr auto ivii = 0b0000000000101010; > + static_assert(ivii == 42, "wrong value"); > + > + } > + > + namespace test_generalized_constexpr > + { > + > + template < typename CharT > > + constexpr unsigned long > + strlen_c(const CharT *const s) noexcept > + { > + auto length = 0UL; > + for (auto p = s; *p; ++p) > + ++length; > + return length; > + } > + > + static_assert(strlen_c("") == 0UL, ""); > + static_assert(strlen_c("x") == 1UL, ""); > + static_assert(strlen_c("test") == 4UL, ""); > + static_assert(strlen_c("another\0test") == 7UL, ""); > + > + } > + > + namespace test_lambda_init_capture > + { > + > + int > + test() > + { > + auto x = 0; > + const auto lambda1 = [a = x](int b){ return a + b; }; > + const auto lambda2 = [a = lambda1(x)](){ return a; }; > + return lambda2(); > + } > + > + } > + > + namespace test_digit_separators > + { > + > + constexpr auto ten_million = 100'000'000; > + static_assert(ten_million == 100000000, ""); > + > + } > + > + namespace test_return_type_deduction > + { > + > + auto f(int& x) { return x; } > + decltype(auto) g(int& x) { return x; } > + > + template < typename T1, typename T2 > > + struct is_same > + { > + static constexpr auto value = false; > + }; > + > + template < typename T > > + struct is_same<T, T> > + { > + static constexpr auto value = true; > + }; > + > + int > + test() > + { > + auto x = 0; > + static_assert(is_same<int, decltype(f(x))>::value, ""); > + static_assert(is_same<int&, decltype(g(x))>::value, ""); > + return x; > + } > + > + } > + > +} // namespace cxx14 > + > +#endif // __cplusplus >= 201402L > + > + > + > _ACEOF > if ac_fn_cxx_try_compile "$LINENO"; then : > eval $cachevar=yes > @@ -6564,9 +6804,9 @@ $as_echo "$ac_res" >&6; } > if test x$ac_success = xno; then > for alternative in ${ax_cxx_compile_alternatives}; do > for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do > - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 > -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } > + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 > +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } > if eval \${$cachevar+:} false; then : > $as_echo_n "(cached) " >&6 > else > @@ -6862,6 +7102,126 @@ namespace cxx11 > > > > + > +// If the compiler admits that it is not ready for C++14, why torture it? > +// Hopefully, this will speed up the test. > + > +#ifndef __cplusplus > + > +#error "This is not a C++ compiler" > + > +#elif __cplusplus < 201402L > + > +#error "This is not a C++14 compiler" > + > +#else > + > +namespace cxx14 > +{ > + > + namespace test_polymorphic_lambdas > + { > + > + int > + test() > + { > + const auto lambda = [](auto&&... args){ > + const auto istiny = [](auto x){ > + return (sizeof(x) == 1UL) ? 1 : 0; > + }; > + const int aretiny[] = { istiny(args)... }; > + return aretiny[0]; > + }; > + return lambda(1, 1L, 1.0f, '1'); > + } > + > + } > + > + namespace test_binary_literals > + { > + > + constexpr auto ivii = 0b0000000000101010; > + static_assert(ivii == 42, "wrong value"); > + > + } > + > + namespace test_generalized_constexpr > + { > + > + template < typename CharT > > + constexpr unsigned long > + strlen_c(const CharT *const s) noexcept > + { > + auto length = 0UL; > + for (auto p = s; *p; ++p) > + ++length; > + return length; > + } > + > + static_assert(strlen_c("") == 0UL, ""); > + static_assert(strlen_c("x") == 1UL, ""); > + static_assert(strlen_c("test") == 4UL, ""); > + static_assert(strlen_c("another\0test") == 7UL, ""); > + > + } > + > + namespace test_lambda_init_capture > + { > + > + int > + test() > + { > + auto x = 0; > + const auto lambda1 = [a = x](int b){ return a + b; }; > + const auto lambda2 = [a = lambda1(x)](){ return a; }; > + return lambda2(); > + } > + > + } > + > + namespace test_digit_separators > + { > + > + constexpr auto ten_million = 100'000'000; > + static_assert(ten_million == 100000000, ""); > + > + } > + > + namespace test_return_type_deduction > + { > + > + auto f(int& x) { return x; } > + decltype(auto) g(int& x) { return x; } > + > + template < typename T1, typename T2 > > + struct is_same > + { > + static constexpr auto value = false; > + }; > + > + template < typename T > > + struct is_same<T, T> > + { > + static constexpr auto value = true; > + }; > + > + int > + test() > + { > + auto x = 0; > + static_assert(is_same<int, decltype(f(x))>::value, ""); > + static_assert(is_same<int&, decltype(g(x))>::value, ""); > + return x; > + } > + > + } > + > +} // namespace cxx14 > + > +#endif // __cplusplus >= 201402L > + > + > + > _ACEOF > if ac_fn_cxx_try_compile "$LINENO"; then : > eval $cachevar=yes > @@ -6895,41 +7255,41 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' > ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' > ac_compiler_gnu=$ac_cv_c_compiler_gnu > > - if test x$ax_cxx_compile_cxx11_required = xtrue; then > + if test x$ax_cxx_compile_cxx14_required = xtrue; then > if test x$ac_success = xno; then > - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 > + as_fn_error $? "*** A compiler with support for C++14 language features is required." "$LINENO" 5 > fi > fi > if test x$ac_success = xno; then > - HAVE_CXX11=0 > - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 > -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} > + HAVE_CXX14=0 > + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++14 support was found" >&5 > +$as_echo "$as_me: No compiler with C++14 support was found" >&6;} > else > - HAVE_CXX11=1 > + HAVE_CXX14=1 > > -$as_echo "#define HAVE_CXX11 1" >>confdefs.h > +$as_echo "#define HAVE_CXX14 1" >>confdefs.h > > fi > > > > if test "${build}" != "${host}"; then > - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true > + ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=true > ac_ext=cpp > ac_cpp='$CXXCPP $CPPFLAGS' > ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' > ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' > ac_compiler_gnu=$ac_cv_cxx_compiler_gnu > ac_success=no > - ax_cv_cxx_compile_cxx11_orig_cxx="$CXX" > - ax_cv_cxx_compile_cxx11_orig_cxxflags="$CXXFLAGS" > - ax_cv_cxx_compile_cxx11_orig_cppflags="$CPPFLAGS" > + ax_cv_cxx_compile_cxx14_orig_cxx="$CXX" > + ax_cv_cxx_compile_cxx14_orig_cxxflags="$CXXFLAGS" > + ax_cv_cxx_compile_cxx14_orig_cppflags="$CPPFLAGS" > CXX="$CXX_FOR_BUILD" > CXXFLAGS="$CXXFLAGS_FOR_BUILD" > CPPFLAGS="$CPPFLAGS_FOR_BUILD" > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 > -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } > -if ${ax_cv_cxx_compile_cxx11_FOR_BUILD+:} false; then : > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features by default" >&5 > +$as_echo_n "checking whether $CXX supports C++14 features by default... " >&6; } > +if ${ax_cv_cxx_compile_cxx14_FOR_BUILD+:} false; then : > $as_echo_n "(cached) " >&6 > else > cat confdefs.h - <<_ACEOF >conftest.$ac_ext > @@ -7222,26 +7582,146 @@ namespace cxx11 > > > > + > +// If the compiler admits that it is not ready for C++14, why torture it? > +// Hopefully, this will speed up the test. > + > +#ifndef __cplusplus > + > +#error "This is not a C++ compiler" > + > +#elif __cplusplus < 201402L > + > +#error "This is not a C++14 compiler" > + > +#else > + > +namespace cxx14 > +{ > + > + namespace test_polymorphic_lambdas > + { > + > + int > + test() > + { > + const auto lambda = [](auto&&... args){ > + const auto istiny = [](auto x){ > + return (sizeof(x) == 1UL) ? 1 : 0; > + }; > + const int aretiny[] = { istiny(args)... }; > + return aretiny[0]; > + }; > + return lambda(1, 1L, 1.0f, '1'); > + } > + > + } > + > + namespace test_binary_literals > + { > + > + constexpr auto ivii = 0b0000000000101010; > + static_assert(ivii == 42, "wrong value"); > + > + } > + > + namespace test_generalized_constexpr > + { > + > + template < typename CharT > > + constexpr unsigned long > + strlen_c(const CharT *const s) noexcept > + { > + auto length = 0UL; > + for (auto p = s; *p; ++p) > + ++length; > + return length; > + } > + > + static_assert(strlen_c("") == 0UL, ""); > + static_assert(strlen_c("x") == 1UL, ""); > + static_assert(strlen_c("test") == 4UL, ""); > + static_assert(strlen_c("another\0test") == 7UL, ""); > + > + } > + > + namespace test_lambda_init_capture > + { > + > + int > + test() > + { > + auto x = 0; > + const auto lambda1 = [a = x](int b){ return a + b; }; > + const auto lambda2 = [a = lambda1(x)](){ return a; }; > + return lambda2(); > + } > + > + } > + > + namespace test_digit_separators > + { > + > + constexpr auto ten_million = 100'000'000; > + static_assert(ten_million == 100000000, ""); > + > + } > + > + namespace test_return_type_deduction > + { > + > + auto f(int& x) { return x; } > + decltype(auto) g(int& x) { return x; } > + > + template < typename T1, typename T2 > > + struct is_same > + { > + static constexpr auto value = false; > + }; > + > + template < typename T > > + struct is_same<T, T> > + { > + static constexpr auto value = true; > + }; > + > + int > + test() > + { > + auto x = 0; > + static_assert(is_same<int, decltype(f(x))>::value, ""); > + static_assert(is_same<int&, decltype(g(x))>::value, ""); > + return x; > + } > + > + } > + > +} // namespace cxx14 > + > +#endif // __cplusplus >= 201402L > + > + > + > _ACEOF > if ac_fn_cxx_try_compile "$LINENO"; then : > - ax_cv_cxx_compile_cxx11_FOR_BUILD=yes > + ax_cv_cxx_compile_cxx14_FOR_BUILD=yes > else > - ax_cv_cxx_compile_cxx11_FOR_BUILD=no > + ax_cv_cxx_compile_cxx14_FOR_BUILD=no > fi > rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > fi > -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11_FOR_BUILD" >&5 > -$as_echo "$ax_cv_cxx_compile_cxx11_FOR_BUILD" >&6; } > - if test x$ax_cv_cxx_compile_cxx11_FOR_BUILD = xyes; then > +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx14_FOR_BUILD" >&5 > +$as_echo "$ax_cv_cxx_compile_cxx14_FOR_BUILD" >&6; } > + if test x$ax_cv_cxx_compile_cxx14_FOR_BUILD = xyes; then > ac_success=yes > fi > > if test x$ac_success = xno; then > for alternative in ${ax_cxx_compile_alternatives}; do > switch="-std=gnu++${alternative}" > - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_FOR_BUILD_$switch" | $as_tr_sh` > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 > -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } > + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_FOR_BUILD_$switch" | $as_tr_sh` > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 > +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } > if eval \${$cachevar+:} false; then : > $as_echo_n "(cached) " >&6 > else > @@ -7537,6 +8017,126 @@ namespace cxx11 > > > > + > +// If the compiler admits that it is not ready for C++14, why torture it? > +// Hopefully, this will speed up the test. > + > +#ifndef __cplusplus > + > +#error "This is not a C++ compiler" > + > +#elif __cplusplus < 201402L > + > +#error "This is not a C++14 compiler" > + > +#else > + > +namespace cxx14 > +{ > + > + namespace test_polymorphic_lambdas > + { > + > + int > + test() > + { > + const auto lambda = [](auto&&... args){ > + const auto istiny = [](auto x){ > + return (sizeof(x) == 1UL) ? 1 : 0; > + }; > + const int aretiny[] = { istiny(args)... }; > + return aretiny[0]; > + }; > + return lambda(1, 1L, 1.0f, '1'); > + } > + > + } > + > + namespace test_binary_literals > + { > + > + constexpr auto ivii = 0b0000000000101010; > + static_assert(ivii == 42, "wrong value"); > + > + } > + > + namespace test_generalized_constexpr > + { > + > + template < typename CharT > > + constexpr unsigned long > + strlen_c(const CharT *const s) noexcept > + { > + auto length = 0UL; > + for (auto p = s; *p; ++p) > + ++length; > + return length; > + } > + > + static_assert(strlen_c("") == 0UL, ""); > + static_assert(strlen_c("x") == 1UL, ""); > + static_assert(strlen_c("test") == 4UL, ""); > + static_assert(strlen_c("another\0test") == 7UL, ""); > + > + } > + > + namespace test_lambda_init_capture > + { > + > + int > + test() > + { > + auto x = 0; > + const auto lambda1 = [a = x](int b){ return a + b; }; > + const auto lambda2 = [a = lambda1(x)](){ return a; }; > + return lambda2(); > + } > + > + } > + > + namespace test_digit_separators > + { > + > + constexpr auto ten_million = 100'000'000; > + static_assert(ten_million == 100000000, ""); > + > + } > + > + namespace test_return_type_deduction > + { > + > + auto f(int& x) { return x; } > + decltype(auto) g(int& x) { return x; } > + > + template < typename T1, typename T2 > > + struct is_same > + { > + static constexpr auto value = false; > + }; > + > + template < typename T > > + struct is_same<T, T> > + { > + static constexpr auto value = true; > + }; > + > + int > + test() > + { > + auto x = 0; > + static_assert(is_same<int, decltype(f(x))>::value, ""); > + static_assert(is_same<int&, decltype(g(x))>::value, ""); > + return x; > + } > + > + } > + > +} // namespace cxx14 > + > +#endif // __cplusplus >= 201402L > + > + > + > _ACEOF > if ac_fn_cxx_try_compile "$LINENO"; then : > eval $cachevar=yes > @@ -7563,9 +8163,9 @@ $as_echo "$ac_res" >&6; } > if test x$ac_success = xno; then > for alternative in ${ax_cxx_compile_alternatives}; do > for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do > - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_FOR_BUILD_$switch" | $as_tr_sh` > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 > -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } > + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_FOR_BUILD_$switch" | $as_tr_sh` > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 > +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } > if eval \${$cachevar+:} false; then : > $as_echo_n "(cached) " >&6 > else > @@ -7861,6 +8461,126 @@ namespace cxx11 > > > > + > +// If the compiler admits that it is not ready for C++14, why torture it? > +// Hopefully, this will speed up the test. > + > +#ifndef __cplusplus > + > +#error "This is not a C++ compiler" > + > +#elif __cplusplus < 201402L > + > +#error "This is not a C++14 compiler" > + > +#else > + > +namespace cxx14 > +{ > + > + namespace test_polymorphic_lambdas > + { > + > + int > + test() > + { > + const auto lambda = [](auto&&... args){ > + const auto istiny = [](auto x){ > + return (sizeof(x) == 1UL) ? 1 : 0; > + }; > + const int aretiny[] = { istiny(args)... }; > + return aretiny[0]; > + }; > + return lambda(1, 1L, 1.0f, '1'); > + } > + > + } > + > + namespace test_binary_literals > + { > + > + constexpr auto ivii = 0b0000000000101010; > + static_assert(ivii == 42, "wrong value"); > + > + } > + > + namespace test_generalized_constexpr > + { > + > + template < typename CharT > > + constexpr unsigned long > + strlen_c(const CharT *const s) noexcept > + { > + auto length = 0UL; > + for (auto p = s; *p; ++p) > + ++length; > + return length; > + } > + > + static_assert(strlen_c("") == 0UL, ""); > + static_assert(strlen_c("x") == 1UL, ""); > + static_assert(strlen_c("test") == 4UL, ""); > + static_assert(strlen_c("another\0test") == 7UL, ""); > + > + } > + > + namespace test_lambda_init_capture > + { > + > + int > + test() > + { > + auto x = 0; > + const auto lambda1 = [a = x](int b){ return a + b; }; > + const auto lambda2 = [a = lambda1(x)](){ return a; }; > + return lambda2(); > + } > + > + } > + > + namespace test_digit_separators > + { > + > + constexpr auto ten_million = 100'000'000; > + static_assert(ten_million == 100000000, ""); > + > + } > + > + namespace test_return_type_deduction > + { > + > + auto f(int& x) { return x; } > + decltype(auto) g(int& x) { return x; } > + > + template < typename T1, typename T2 > > + struct is_same > + { > + static constexpr auto value = false; > + }; > + > + template < typename T > > + struct is_same<T, T> > + { > + static constexpr auto value = true; > + }; > + > + int > + test() > + { > + auto x = 0; > + static_assert(is_same<int, decltype(f(x))>::value, ""); > + static_assert(is_same<int&, decltype(g(x))>::value, ""); > + return x; > + } > + > + } > + > +} // namespace cxx14 > + > +#endif // __cplusplus >= 201402L > + > + > + > _ACEOF > if ac_fn_cxx_try_compile "$LINENO"; then : > eval $cachevar=yes > @@ -7890,28 +8610,28 @@ $as_echo "$ac_res" >&6; } > CXX_FOR_BUILD="$CXX" > CXXFLAGS_FOR_BUILD="$CXXFLAGS" > CPPFLAGS_FOR_BUILD="$CPPFLAGS" > - CXX="$ax_cv_cxx_compile_cxx11_orig_cxx" > - CXXFLAGS="$ax_cv_cxx_compile_cxx11_orig_cxxflags" > - CPPFLAGS="$ax_cv_cxx_compile_cxx11_orig_cppflags" > + CXX="$ax_cv_cxx_compile_cxx14_orig_cxx" > + CXXFLAGS="$ax_cv_cxx_compile_cxx14_orig_cxxflags" > + CPPFLAGS="$ax_cv_cxx_compile_cxx14_orig_cppflags" > ac_ext=c > ac_cpp='$CPP $CPPFLAGS' > ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' > ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' > ac_compiler_gnu=$ac_cv_c_compiler_gnu > > - if test x$ax_cxx_compile_cxx11_required = xtrue; then > + if test x$ax_cxx_compile_cxx14_required = xtrue; then > if test x$ac_success = xno; then > - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 > + as_fn_error $? "*** A compiler with support for C++14 language features is required." "$LINENO" 5 > fi > fi > if test x$ac_success = xno; then > - HAVE_CXX11_FOR_BUILD=0 > - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 > -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} > + HAVE_CXX14_FOR_BUILD=0 > + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++14 support was found" >&5 > +$as_echo "$as_me: No compiler with C++14 support was found" >&6;} > else > - HAVE_CXX11_FOR_BUILD=1 > + HAVE_CXX14_FOR_BUILD=1 > > -$as_echo "#define HAVE_CXX11_FOR_BUILD 1" >>confdefs.h > +$as_echo "#define HAVE_CXX14_FOR_BUILD 1" >>confdefs.h > > fi > > > base-commit: 5c8f9f4d4cebabf85e68c5bdbe2d4ee6646edc7c > -- > 2.46.0 >
On 9/18/24 6:36 PM, Iain Sandoe wrote: > > >> On 18 Sep 2024, at 17:18, Jason Merrill <jason@redhat.com> wrote: >> >> Tested x86_64-pc-linux-gnu with 5.5.0 bootstrap compiler. Thoughts? > > Despite that adequate support is available in GCC-5.5/6, would it be > useful to jump to a version that allows a single toolchain to bootstrap > all the currently supported languages (currently we have 4.8.x for the > c-family+fortran, 5 for Ada and 9 for D which is somewhat unhelpful > for folks who test all supported langs). Hmm, people are certainly encouraged to bootstrap with GCC 9 if they want D support, but I wouldn't list it as a requirement for building GCC at all. The cost of unnecessarily cutting off older installations seems to me a poor tradeoff. >> -- 8< -- >> >> This implements my proposal to update our bootstrap requirement to C++14. >> The big benefit of the change is the greater constexpr power, but C++14 also >> added variable templates, generic lambdas, lambda init-capture, binary >> literals, and numeric literal digit separators. >> >> I'm not sure which GCC version to mention here. C++14 was feature-complete >> in GCC 5, and became the default in GCC 6. 5.5.0 builds trunk with no >> trouble, but of course trunk also doesn't use any C++14 features. Looking >> at bugzilla, I see only one C++14 fix (PR71630) in 5.5, and it doesn't seem >> important. In 5.4, PR69995 seems potentially significant, so shall we >> recommend 5.4 or later? Or just say 5.5 because people are unlikely to be >> stuck on an earlier minor release? >> >> gcc/ChangeLog: >> >> * doc/install.texi (Prerequisites): Update to C++14. >> >> ChangeLog: >> >> * configure.ac: Update requirement to C++14. >> * configure: Regenerate. >> --- >> gcc/doc/install.texi | 15 +- >> configure.ac | 12 +- >> configure | 832 ++++++++++++++++++++++++++++++++++++++++--- >> 3 files changed, 790 insertions(+), 69 deletions(-) >> >> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi >> index e339d736969..87add0b6572 100644 >> --- a/gcc/doc/install.texi >> +++ b/gcc/doc/install.texi >> @@ -222,17 +222,18 @@ described below. >> >> @heading Tools/packages necessary for building GCC >> @table @asis >> -@item ISO C++11 compiler >> -Necessary to bootstrap GCC. GCC 4.8.3 or newer has sufficient >> -support for used C++11 features. >> +@item ISO C++14 compiler >> +Necessary to bootstrap GCC. GCC 5.5 or newer has sufficient >> +support for used C++14 features. >> >> -Versions of GCC prior to 11 also allow bootstrapping with an ISO C++98 >> -compiler, and versions of GCC prior to 4.8 also allow bootstrapping with >> -an ISO C89 compiler. >> +Versions of GCC prior to 15 allow bootstrapping with an ISO C++11 >> +compiler, versions prior to 11 allow bootstrapping with an ISO C++98 >> +compiler, and versions prior to 4.8 allow bootstrapping with an ISO >> +C89 compiler. >> >> To build all languages in a cross-compiler or other configuration where >> 3-stage bootstrap is not performed, you need to start with an existing >> -GCC binary (version 4.8.3 or later) because source code for language >> +GCC binary (version 5.5 or later) because source code for language >> frontends other than C might use GCC extensions. >> >> @item C standard library and headers >> diff --git a/configure.ac b/configure.ac >> index f61dbe64a94..91635d5368a 100644 >> --- a/configure.ac >> +++ b/configure.ac >> @@ -1457,16 +1457,16 @@ case "$have_compiler:$host:$target:$enable_bootstrap" in >> ;; >> esac >> >> -# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a >> -# C++11 compiler can still start the bootstrap. Otherwise, if building GCC, >> -# require C++11 (or higher). >> +# When bootstrapping with GCC, build stage 1 in C++14 mode to ensure that a >> +# C++14 compiler can still start the bootstrap. Otherwise, if building GCC, >> +# require C++14 (or higher). >> if test "$enable_bootstrap:$GXX" = "yes:yes"; then >> - CXX="$CXX -std=c++11" >> + CXX="$CXX -std=c++14" >> elif test "$have_compiler" = yes; then >> - AX_CXX_COMPILE_STDCXX(11) >> + AX_CXX_COMPILE_STDCXX(14) >> >> if test "${build}" != "${host}"; then >> - AX_CXX_COMPILE_STDCXX(11, [], [], [_FOR_BUILD]) >> + AX_CXX_COMPILE_STDCXX(14, [], [], [_FOR_BUILD]) >> fi >> fi >> >> diff --git a/configure b/configure >> index e9583f2ba0c..ab9719c6e93 100755 >> --- a/configure >> +++ b/configure >> @@ -712,8 +712,8 @@ gmplibs >> PGO_BUILD_LTO_CFLAGS >> PGO_BUILD_USE_CFLAGS >> PGO_BUILD_GEN_CFLAGS >> -HAVE_CXX11_FOR_BUILD >> -HAVE_CXX11 >> +HAVE_CXX14_FOR_BUILD >> +HAVE_CXX14 >> do_compare >> CARGO >> GDC >> @@ -5914,13 +5914,13 @@ $as_echo "$as_me: WARNING: trying to bootstrap a cross compiler" >&2;} >> ;; >> esac >> >> -# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a >> -# C++11 compiler can still start the bootstrap. Otherwise, if building GCC, >> -# require C++11 (or higher). >> +# When bootstrapping with GCC, build stage 1 in C++14 mode to ensure that a >> +# C++14 compiler can still start the bootstrap. Otherwise, if building GCC, >> +# require C++14 (or higher). >> if test "$enable_bootstrap:$GXX" = "yes:yes"; then >> - CXX="$CXX -std=c++11" >> + CXX="$CXX -std=c++14" >> elif test "$have_compiler" = yes; then >> - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true >> + ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=true >> ac_ext=cpp >> ac_cpp='$CXXCPP $CPPFLAGS' >> ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' >> @@ -5928,9 +5928,9 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex >> ac_compiler_gnu=$ac_cv_cxx_compiler_gnu >> ac_success=no >> >> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 >> -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } >> -if ${ax_cv_cxx_compile_cxx11+:} false; then : >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features by default" >&5 >> +$as_echo_n "checking whether $CXX supports C++14 features by default... " >&6; } >> +if ${ax_cv_cxx_compile_cxx14+:} false; then : >> $as_echo_n "(cached) " >&6 >> else >> cat confdefs.h - <<_ACEOF >conftest.$ac_ext >> @@ -6223,26 +6223,146 @@ namespace cxx11 >> >> >> >> + >> +// If the compiler admits that it is not ready for C++14, why torture it? >> +// Hopefully, this will speed up the test. >> + >> +#ifndef __cplusplus >> + >> +#error "This is not a C++ compiler" >> + >> +#elif __cplusplus < 201402L >> + >> +#error "This is not a C++14 compiler" >> + >> +#else >> + >> +namespace cxx14 >> +{ >> + >> + namespace test_polymorphic_lambdas >> + { >> + >> + int >> + test() >> + { >> + const auto lambda = [](auto&&... args){ >> + const auto istiny = [](auto x){ >> + return (sizeof(x) == 1UL) ? 1 : 0; >> + }; >> + const int aretiny[] = { istiny(args)... }; >> + return aretiny[0]; >> + }; >> + return lambda(1, 1L, 1.0f, '1'); >> + } >> + >> + } >> + >> + namespace test_binary_literals >> + { >> + >> + constexpr auto ivii = 0b0000000000101010; >> + static_assert(ivii == 42, "wrong value"); >> + >> + } >> + >> + namespace test_generalized_constexpr >> + { >> + >> + template < typename CharT > >> + constexpr unsigned long >> + strlen_c(const CharT *const s) noexcept >> + { >> + auto length = 0UL; >> + for (auto p = s; *p; ++p) >> + ++length; >> + return length; >> + } >> + >> + static_assert(strlen_c("") == 0UL, ""); >> + static_assert(strlen_c("x") == 1UL, ""); >> + static_assert(strlen_c("test") == 4UL, ""); >> + static_assert(strlen_c("another\0test") == 7UL, ""); >> + >> + } >> + >> + namespace test_lambda_init_capture >> + { >> + >> + int >> + test() >> + { >> + auto x = 0; >> + const auto lambda1 = [a = x](int b){ return a + b; }; >> + const auto lambda2 = [a = lambda1(x)](){ return a; }; >> + return lambda2(); >> + } >> + >> + } >> + >> + namespace test_digit_separators >> + { >> + >> + constexpr auto ten_million = 100'000'000; >> + static_assert(ten_million == 100000000, ""); >> + >> + } >> + >> + namespace test_return_type_deduction >> + { >> + >> + auto f(int& x) { return x; } >> + decltype(auto) g(int& x) { return x; } >> + >> + template < typename T1, typename T2 > >> + struct is_same >> + { >> + static constexpr auto value = false; >> + }; >> + >> + template < typename T > >> + struct is_same<T, T> >> + { >> + static constexpr auto value = true; >> + }; >> + >> + int >> + test() >> + { >> + auto x = 0; >> + static_assert(is_same<int, decltype(f(x))>::value, ""); >> + static_assert(is_same<int&, decltype(g(x))>::value, ""); >> + return x; >> + } >> + >> + } >> + >> +} // namespace cxx14 >> + >> +#endif // __cplusplus >= 201402L >> + >> + >> + >> _ACEOF >> if ac_fn_cxx_try_compile "$LINENO"; then : >> - ax_cv_cxx_compile_cxx11=yes >> + ax_cv_cxx_compile_cxx14=yes >> else >> - ax_cv_cxx_compile_cxx11=no >> + ax_cv_cxx_compile_cxx14=no >> fi >> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext >> fi >> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 >> -$as_echo "$ax_cv_cxx_compile_cxx11" >&6; } >> - if test x$ax_cv_cxx_compile_cxx11 = xyes; then >> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx14" >&5 >> +$as_echo "$ax_cv_cxx_compile_cxx14" >&6; } >> + if test x$ax_cv_cxx_compile_cxx14 = xyes; then >> ac_success=yes >> fi >> >> if test x$ac_success = xno; then >> for alternative in ${ax_cxx_compile_alternatives}; do >> switch="-std=gnu++${alternative}" >> - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` >> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 >> -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } >> + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 >> +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } >> if eval \${$cachevar+:} false; then : >> $as_echo_n "(cached) " >&6 >> else >> @@ -6538,6 +6658,126 @@ namespace cxx11 >> >> >> >> + >> +// If the compiler admits that it is not ready for C++14, why torture it? >> +// Hopefully, this will speed up the test. >> + >> +#ifndef __cplusplus >> + >> +#error "This is not a C++ compiler" >> + >> +#elif __cplusplus < 201402L >> + >> +#error "This is not a C++14 compiler" >> + >> +#else >> + >> +namespace cxx14 >> +{ >> + >> + namespace test_polymorphic_lambdas >> + { >> + >> + int >> + test() >> + { >> + const auto lambda = [](auto&&... args){ >> + const auto istiny = [](auto x){ >> + return (sizeof(x) == 1UL) ? 1 : 0; >> + }; >> + const int aretiny[] = { istiny(args)... }; >> + return aretiny[0]; >> + }; >> + return lambda(1, 1L, 1.0f, '1'); >> + } >> + >> + } >> + >> + namespace test_binary_literals >> + { >> + >> + constexpr auto ivii = 0b0000000000101010; >> + static_assert(ivii == 42, "wrong value"); >> + >> + } >> + >> + namespace test_generalized_constexpr >> + { >> + >> + template < typename CharT > >> + constexpr unsigned long >> + strlen_c(const CharT *const s) noexcept >> + { >> + auto length = 0UL; >> + for (auto p = s; *p; ++p) >> + ++length; >> + return length; >> + } >> + >> + static_assert(strlen_c("") == 0UL, ""); >> + static_assert(strlen_c("x") == 1UL, ""); >> + static_assert(strlen_c("test") == 4UL, ""); >> + static_assert(strlen_c("another\0test") == 7UL, ""); >> + >> + } >> + >> + namespace test_lambda_init_capture >> + { >> + >> + int >> + test() >> + { >> + auto x = 0; >> + const auto lambda1 = [a = x](int b){ return a + b; }; >> + const auto lambda2 = [a = lambda1(x)](){ return a; }; >> + return lambda2(); >> + } >> + >> + } >> + >> + namespace test_digit_separators >> + { >> + >> + constexpr auto ten_million = 100'000'000; >> + static_assert(ten_million == 100000000, ""); >> + >> + } >> + >> + namespace test_return_type_deduction >> + { >> + >> + auto f(int& x) { return x; } >> + decltype(auto) g(int& x) { return x; } >> + >> + template < typename T1, typename T2 > >> + struct is_same >> + { >> + static constexpr auto value = false; >> + }; >> + >> + template < typename T > >> + struct is_same<T, T> >> + { >> + static constexpr auto value = true; >> + }; >> + >> + int >> + test() >> + { >> + auto x = 0; >> + static_assert(is_same<int, decltype(f(x))>::value, ""); >> + static_assert(is_same<int&, decltype(g(x))>::value, ""); >> + return x; >> + } >> + >> + } >> + >> +} // namespace cxx14 >> + >> +#endif // __cplusplus >= 201402L >> + >> + >> + >> _ACEOF >> if ac_fn_cxx_try_compile "$LINENO"; then : >> eval $cachevar=yes >> @@ -6564,9 +6804,9 @@ $as_echo "$ac_res" >&6; } >> if test x$ac_success = xno; then >> for alternative in ${ax_cxx_compile_alternatives}; do >> for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do >> - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` >> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 >> -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } >> + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 >> +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } >> if eval \${$cachevar+:} false; then : >> $as_echo_n "(cached) " >&6 >> else >> @@ -6862,6 +7102,126 @@ namespace cxx11 >> >> >> >> + >> +// If the compiler admits that it is not ready for C++14, why torture it? >> +// Hopefully, this will speed up the test. >> + >> +#ifndef __cplusplus >> + >> +#error "This is not a C++ compiler" >> + >> +#elif __cplusplus < 201402L >> + >> +#error "This is not a C++14 compiler" >> + >> +#else >> + >> +namespace cxx14 >> +{ >> + >> + namespace test_polymorphic_lambdas >> + { >> + >> + int >> + test() >> + { >> + const auto lambda = [](auto&&... args){ >> + const auto istiny = [](auto x){ >> + return (sizeof(x) == 1UL) ? 1 : 0; >> + }; >> + const int aretiny[] = { istiny(args)... }; >> + return aretiny[0]; >> + }; >> + return lambda(1, 1L, 1.0f, '1'); >> + } >> + >> + } >> + >> + namespace test_binary_literals >> + { >> + >> + constexpr auto ivii = 0b0000000000101010; >> + static_assert(ivii == 42, "wrong value"); >> + >> + } >> + >> + namespace test_generalized_constexpr >> + { >> + >> + template < typename CharT > >> + constexpr unsigned long >> + strlen_c(const CharT *const s) noexcept >> + { >> + auto length = 0UL; >> + for (auto p = s; *p; ++p) >> + ++length; >> + return length; >> + } >> + >> + static_assert(strlen_c("") == 0UL, ""); >> + static_assert(strlen_c("x") == 1UL, ""); >> + static_assert(strlen_c("test") == 4UL, ""); >> + static_assert(strlen_c("another\0test") == 7UL, ""); >> + >> + } >> + >> + namespace test_lambda_init_capture >> + { >> + >> + int >> + test() >> + { >> + auto x = 0; >> + const auto lambda1 = [a = x](int b){ return a + b; }; >> + const auto lambda2 = [a = lambda1(x)](){ return a; }; >> + return lambda2(); >> + } >> + >> + } >> + >> + namespace test_digit_separators >> + { >> + >> + constexpr auto ten_million = 100'000'000; >> + static_assert(ten_million == 100000000, ""); >> + >> + } >> + >> + namespace test_return_type_deduction >> + { >> + >> + auto f(int& x) { return x; } >> + decltype(auto) g(int& x) { return x; } >> + >> + template < typename T1, typename T2 > >> + struct is_same >> + { >> + static constexpr auto value = false; >> + }; >> + >> + template < typename T > >> + struct is_same<T, T> >> + { >> + static constexpr auto value = true; >> + }; >> + >> + int >> + test() >> + { >> + auto x = 0; >> + static_assert(is_same<int, decltype(f(x))>::value, ""); >> + static_assert(is_same<int&, decltype(g(x))>::value, ""); >> + return x; >> + } >> + >> + } >> + >> +} // namespace cxx14 >> + >> +#endif // __cplusplus >= 201402L >> + >> + >> + >> _ACEOF >> if ac_fn_cxx_try_compile "$LINENO"; then : >> eval $cachevar=yes >> @@ -6895,41 +7255,41 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' >> ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' >> ac_compiler_gnu=$ac_cv_c_compiler_gnu >> >> - if test x$ax_cxx_compile_cxx11_required = xtrue; then >> + if test x$ax_cxx_compile_cxx14_required = xtrue; then >> if test x$ac_success = xno; then >> - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 >> + as_fn_error $? "*** A compiler with support for C++14 language features is required." "$LINENO" 5 >> fi >> fi >> if test x$ac_success = xno; then >> - HAVE_CXX11=0 >> - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 >> -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} >> + HAVE_CXX14=0 >> + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++14 support was found" >&5 >> +$as_echo "$as_me: No compiler with C++14 support was found" >&6;} >> else >> - HAVE_CXX11=1 >> + HAVE_CXX14=1 >> >> -$as_echo "#define HAVE_CXX11 1" >>confdefs.h >> +$as_echo "#define HAVE_CXX14 1" >>confdefs.h >> >> fi >> >> >> >> if test "${build}" != "${host}"; then >> - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true >> + ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=true >> ac_ext=cpp >> ac_cpp='$CXXCPP $CPPFLAGS' >> ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' >> ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' >> ac_compiler_gnu=$ac_cv_cxx_compiler_gnu >> ac_success=no >> - ax_cv_cxx_compile_cxx11_orig_cxx="$CXX" >> - ax_cv_cxx_compile_cxx11_orig_cxxflags="$CXXFLAGS" >> - ax_cv_cxx_compile_cxx11_orig_cppflags="$CPPFLAGS" >> + ax_cv_cxx_compile_cxx14_orig_cxx="$CXX" >> + ax_cv_cxx_compile_cxx14_orig_cxxflags="$CXXFLAGS" >> + ax_cv_cxx_compile_cxx14_orig_cppflags="$CPPFLAGS" >> CXX="$CXX_FOR_BUILD" >> CXXFLAGS="$CXXFLAGS_FOR_BUILD" >> CPPFLAGS="$CPPFLAGS_FOR_BUILD" >> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 >> -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } >> -if ${ax_cv_cxx_compile_cxx11_FOR_BUILD+:} false; then : >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features by default" >&5 >> +$as_echo_n "checking whether $CXX supports C++14 features by default... " >&6; } >> +if ${ax_cv_cxx_compile_cxx14_FOR_BUILD+:} false; then : >> $as_echo_n "(cached) " >&6 >> else >> cat confdefs.h - <<_ACEOF >conftest.$ac_ext >> @@ -7222,26 +7582,146 @@ namespace cxx11 >> >> >> >> + >> +// If the compiler admits that it is not ready for C++14, why torture it? >> +// Hopefully, this will speed up the test. >> + >> +#ifndef __cplusplus >> + >> +#error "This is not a C++ compiler" >> + >> +#elif __cplusplus < 201402L >> + >> +#error "This is not a C++14 compiler" >> + >> +#else >> + >> +namespace cxx14 >> +{ >> + >> + namespace test_polymorphic_lambdas >> + { >> + >> + int >> + test() >> + { >> + const auto lambda = [](auto&&... args){ >> + const auto istiny = [](auto x){ >> + return (sizeof(x) == 1UL) ? 1 : 0; >> + }; >> + const int aretiny[] = { istiny(args)... }; >> + return aretiny[0]; >> + }; >> + return lambda(1, 1L, 1.0f, '1'); >> + } >> + >> + } >> + >> + namespace test_binary_literals >> + { >> + >> + constexpr auto ivii = 0b0000000000101010; >> + static_assert(ivii == 42, "wrong value"); >> + >> + } >> + >> + namespace test_generalized_constexpr >> + { >> + >> + template < typename CharT > >> + constexpr unsigned long >> + strlen_c(const CharT *const s) noexcept >> + { >> + auto length = 0UL; >> + for (auto p = s; *p; ++p) >> + ++length; >> + return length; >> + } >> + >> + static_assert(strlen_c("") == 0UL, ""); >> + static_assert(strlen_c("x") == 1UL, ""); >> + static_assert(strlen_c("test") == 4UL, ""); >> + static_assert(strlen_c("another\0test") == 7UL, ""); >> + >> + } >> + >> + namespace test_lambda_init_capture >> + { >> + >> + int >> + test() >> + { >> + auto x = 0; >> + const auto lambda1 = [a = x](int b){ return a + b; }; >> + const auto lambda2 = [a = lambda1(x)](){ return a; }; >> + return lambda2(); >> + } >> + >> + } >> + >> + namespace test_digit_separators >> + { >> + >> + constexpr auto ten_million = 100'000'000; >> + static_assert(ten_million == 100000000, ""); >> + >> + } >> + >> + namespace test_return_type_deduction >> + { >> + >> + auto f(int& x) { return x; } >> + decltype(auto) g(int& x) { return x; } >> + >> + template < typename T1, typename T2 > >> + struct is_same >> + { >> + static constexpr auto value = false; >> + }; >> + >> + template < typename T > >> + struct is_same<T, T> >> + { >> + static constexpr auto value = true; >> + }; >> + >> + int >> + test() >> + { >> + auto x = 0; >> + static_assert(is_same<int, decltype(f(x))>::value, ""); >> + static_assert(is_same<int&, decltype(g(x))>::value, ""); >> + return x; >> + } >> + >> + } >> + >> +} // namespace cxx14 >> + >> +#endif // __cplusplus >= 201402L >> + >> + >> + >> _ACEOF >> if ac_fn_cxx_try_compile "$LINENO"; then : >> - ax_cv_cxx_compile_cxx11_FOR_BUILD=yes >> + ax_cv_cxx_compile_cxx14_FOR_BUILD=yes >> else >> - ax_cv_cxx_compile_cxx11_FOR_BUILD=no >> + ax_cv_cxx_compile_cxx14_FOR_BUILD=no >> fi >> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext >> fi >> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11_FOR_BUILD" >&5 >> -$as_echo "$ax_cv_cxx_compile_cxx11_FOR_BUILD" >&6; } >> - if test x$ax_cv_cxx_compile_cxx11_FOR_BUILD = xyes; then >> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx14_FOR_BUILD" >&5 >> +$as_echo "$ax_cv_cxx_compile_cxx14_FOR_BUILD" >&6; } >> + if test x$ax_cv_cxx_compile_cxx14_FOR_BUILD = xyes; then >> ac_success=yes >> fi >> >> if test x$ac_success = xno; then >> for alternative in ${ax_cxx_compile_alternatives}; do >> switch="-std=gnu++${alternative}" >> - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_FOR_BUILD_$switch" | $as_tr_sh` >> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 >> -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } >> + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_FOR_BUILD_$switch" | $as_tr_sh` >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 >> +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } >> if eval \${$cachevar+:} false; then : >> $as_echo_n "(cached) " >&6 >> else >> @@ -7537,6 +8017,126 @@ namespace cxx11 >> >> >> >> + >> +// If the compiler admits that it is not ready for C++14, why torture it? >> +// Hopefully, this will speed up the test. >> + >> +#ifndef __cplusplus >> + >> +#error "This is not a C++ compiler" >> + >> +#elif __cplusplus < 201402L >> + >> +#error "This is not a C++14 compiler" >> + >> +#else >> + >> +namespace cxx14 >> +{ >> + >> + namespace test_polymorphic_lambdas >> + { >> + >> + int >> + test() >> + { >> + const auto lambda = [](auto&&... args){ >> + const auto istiny = [](auto x){ >> + return (sizeof(x) == 1UL) ? 1 : 0; >> + }; >> + const int aretiny[] = { istiny(args)... }; >> + return aretiny[0]; >> + }; >> + return lambda(1, 1L, 1.0f, '1'); >> + } >> + >> + } >> + >> + namespace test_binary_literals >> + { >> + >> + constexpr auto ivii = 0b0000000000101010; >> + static_assert(ivii == 42, "wrong value"); >> + >> + } >> + >> + namespace test_generalized_constexpr >> + { >> + >> + template < typename CharT > >> + constexpr unsigned long >> + strlen_c(const CharT *const s) noexcept >> + { >> + auto length = 0UL; >> + for (auto p = s; *p; ++p) >> + ++length; >> + return length; >> + } >> + >> + static_assert(strlen_c("") == 0UL, ""); >> + static_assert(strlen_c("x") == 1UL, ""); >> + static_assert(strlen_c("test") == 4UL, ""); >> + static_assert(strlen_c("another\0test") == 7UL, ""); >> + >> + } >> + >> + namespace test_lambda_init_capture >> + { >> + >> + int >> + test() >> + { >> + auto x = 0; >> + const auto lambda1 = [a = x](int b){ return a + b; }; >> + const auto lambda2 = [a = lambda1(x)](){ return a; }; >> + return lambda2(); >> + } >> + >> + } >> + >> + namespace test_digit_separators >> + { >> + >> + constexpr auto ten_million = 100'000'000; >> + static_assert(ten_million == 100000000, ""); >> + >> + } >> + >> + namespace test_return_type_deduction >> + { >> + >> + auto f(int& x) { return x; } >> + decltype(auto) g(int& x) { return x; } >> + >> + template < typename T1, typename T2 > >> + struct is_same >> + { >> + static constexpr auto value = false; >> + }; >> + >> + template < typename T > >> + struct is_same<T, T> >> + { >> + static constexpr auto value = true; >> + }; >> + >> + int >> + test() >> + { >> + auto x = 0; >> + static_assert(is_same<int, decltype(f(x))>::value, ""); >> + static_assert(is_same<int&, decltype(g(x))>::value, ""); >> + return x; >> + } >> + >> + } >> + >> +} // namespace cxx14 >> + >> +#endif // __cplusplus >= 201402L >> + >> + >> + >> _ACEOF >> if ac_fn_cxx_try_compile "$LINENO"; then : >> eval $cachevar=yes >> @@ -7563,9 +8163,9 @@ $as_echo "$ac_res" >&6; } >> if test x$ac_success = xno; then >> for alternative in ${ax_cxx_compile_alternatives}; do >> for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do >> - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_FOR_BUILD_$switch" | $as_tr_sh` >> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 >> -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } >> + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_FOR_BUILD_$switch" | $as_tr_sh` >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 >> +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } >> if eval \${$cachevar+:} false; then : >> $as_echo_n "(cached) " >&6 >> else >> @@ -7861,6 +8461,126 @@ namespace cxx11 >> >> >> >> + >> +// If the compiler admits that it is not ready for C++14, why torture it? >> +// Hopefully, this will speed up the test. >> + >> +#ifndef __cplusplus >> + >> +#error "This is not a C++ compiler" >> + >> +#elif __cplusplus < 201402L >> + >> +#error "This is not a C++14 compiler" >> + >> +#else >> + >> +namespace cxx14 >> +{ >> + >> + namespace test_polymorphic_lambdas >> + { >> + >> + int >> + test() >> + { >> + const auto lambda = [](auto&&... args){ >> + const auto istiny = [](auto x){ >> + return (sizeof(x) == 1UL) ? 1 : 0; >> + }; >> + const int aretiny[] = { istiny(args)... }; >> + return aretiny[0]; >> + }; >> + return lambda(1, 1L, 1.0f, '1'); >> + } >> + >> + } >> + >> + namespace test_binary_literals >> + { >> + >> + constexpr auto ivii = 0b0000000000101010; >> + static_assert(ivii == 42, "wrong value"); >> + >> + } >> + >> + namespace test_generalized_constexpr >> + { >> + >> + template < typename CharT > >> + constexpr unsigned long >> + strlen_c(const CharT *const s) noexcept >> + { >> + auto length = 0UL; >> + for (auto p = s; *p; ++p) >> + ++length; >> + return length; >> + } >> + >> + static_assert(strlen_c("") == 0UL, ""); >> + static_assert(strlen_c("x") == 1UL, ""); >> + static_assert(strlen_c("test") == 4UL, ""); >> + static_assert(strlen_c("another\0test") == 7UL, ""); >> + >> + } >> + >> + namespace test_lambda_init_capture >> + { >> + >> + int >> + test() >> + { >> + auto x = 0; >> + const auto lambda1 = [a = x](int b){ return a + b; }; >> + const auto lambda2 = [a = lambda1(x)](){ return a; }; >> + return lambda2(); >> + } >> + >> + } >> + >> + namespace test_digit_separators >> + { >> + >> + constexpr auto ten_million = 100'000'000; >> + static_assert(ten_million == 100000000, ""); >> + >> + } >> + >> + namespace test_return_type_deduction >> + { >> + >> + auto f(int& x) { return x; } >> + decltype(auto) g(int& x) { return x; } >> + >> + template < typename T1, typename T2 > >> + struct is_same >> + { >> + static constexpr auto value = false; >> + }; >> + >> + template < typename T > >> + struct is_same<T, T> >> + { >> + static constexpr auto value = true; >> + }; >> + >> + int >> + test() >> + { >> + auto x = 0; >> + static_assert(is_same<int, decltype(f(x))>::value, ""); >> + static_assert(is_same<int&, decltype(g(x))>::value, ""); >> + return x; >> + } >> + >> + } >> + >> +} // namespace cxx14 >> + >> +#endif // __cplusplus >= 201402L >> + >> + >> + >> _ACEOF >> if ac_fn_cxx_try_compile "$LINENO"; then : >> eval $cachevar=yes >> @@ -7890,28 +8610,28 @@ $as_echo "$ac_res" >&6; } >> CXX_FOR_BUILD="$CXX" >> CXXFLAGS_FOR_BUILD="$CXXFLAGS" >> CPPFLAGS_FOR_BUILD="$CPPFLAGS" >> - CXX="$ax_cv_cxx_compile_cxx11_orig_cxx" >> - CXXFLAGS="$ax_cv_cxx_compile_cxx11_orig_cxxflags" >> - CPPFLAGS="$ax_cv_cxx_compile_cxx11_orig_cppflags" >> + CXX="$ax_cv_cxx_compile_cxx14_orig_cxx" >> + CXXFLAGS="$ax_cv_cxx_compile_cxx14_orig_cxxflags" >> + CPPFLAGS="$ax_cv_cxx_compile_cxx14_orig_cppflags" >> ac_ext=c >> ac_cpp='$CPP $CPPFLAGS' >> ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' >> ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' >> ac_compiler_gnu=$ac_cv_c_compiler_gnu >> >> - if test x$ax_cxx_compile_cxx11_required = xtrue; then >> + if test x$ax_cxx_compile_cxx14_required = xtrue; then >> if test x$ac_success = xno; then >> - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 >> + as_fn_error $? "*** A compiler with support for C++14 language features is required." "$LINENO" 5 >> fi >> fi >> if test x$ac_success = xno; then >> - HAVE_CXX11_FOR_BUILD=0 >> - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 >> -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} >> + HAVE_CXX14_FOR_BUILD=0 >> + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++14 support was found" >&5 >> +$as_echo "$as_me: No compiler with C++14 support was found" >&6;} >> else >> - HAVE_CXX11_FOR_BUILD=1 >> + HAVE_CXX14_FOR_BUILD=1 >> >> -$as_echo "#define HAVE_CXX11_FOR_BUILD 1" >>confdefs.h >> +$as_echo "#define HAVE_CXX14_FOR_BUILD 1" >>confdefs.h >> >> fi >> >> >> base-commit: 5c8f9f4d4cebabf85e68c5bdbe2d4ee6646edc7c >> -- >> 2.46.0 >> >
Jason Merrill <jason@redhat.com> writes: > Tested x86_64-pc-linux-gnu with 5.5.0 bootstrap compiler. Thoughts? > > -- 8< -- > > This implements my proposal to update our bootstrap requirement to C++14. > The big benefit of the change is the greater constexpr power, but C++14 also > added variable templates, generic lambdas, lambda init-capture, binary > literals, and numeric literal digit separators. > > I'm not sure which GCC version to mention here. C++14 was feature-complete > in GCC 5, and became the default in GCC 6. 5.5.0 builds trunk with no > trouble, but of course trunk also doesn't use any C++14 features. Looking > at bugzilla, I see only one C++14 fix (PR71630) in 5.5, and it doesn't seem > important. In 5.4, PR69995 seems potentially significant, so shall we > recommend 5.4 or later? Or just say 5.5 because people are unlikely to be > stuck on an earlier minor release? > Roger, do we need to somehow figure out getting you on a newer GCC for bootstrapping? I know you're currently using an older RHEL or similar on the machines you do testing on. > [...] thanks, sam
1. GNAT needs GCC 5.1 or later 2. Ubuntu 16.04 uses GCC 5.4 3. The propose is bump to GCC 5.5 4. Debian 9 uses GCC 6.3 5. D need GCC 9.4 or later GCC 9.4 is obviously too new, and using GCC 5.5 rules out Ubuntu 16.04. So unless there is a strong reason to do so, it is recommended to bump to GCC 5.4. On Thu, Sep 19, 2024 at 12:59 AM Jason Merrill <jason@redhat.com> wrote: > > On 9/18/24 6:36 PM, Iain Sandoe wrote: > > > > > >> On 18 Sep 2024, at 17:18, Jason Merrill <jason@redhat.com> wrote: > >> > >> Tested x86_64-pc-linux-gnu with 5.5.0 bootstrap compiler. Thoughts? > > > > Despite that adequate support is available in GCC-5.5/6, would it be > > useful to jump to a version that allows a single toolchain to bootstrap > > all the currently supported languages (currently we have 4.8.x for the > > c-family+fortran, 5 for Ada and 9 for D which is somewhat unhelpful > > for folks who test all supported langs). > > Hmm, people are certainly encouraged to bootstrap with GCC 9 if they > want D support, but I wouldn't list it as a requirement for building GCC > at all. The cost of unnecessarily cutting off older installations seems > to me a poor tradeoff. > > >> -- 8< -- > >> > >> This implements my proposal to update our bootstrap requirement to C++14. > >> The big benefit of the change is the greater constexpr power, but C++14 also > >> added variable templates, generic lambdas, lambda init-capture, binary > >> literals, and numeric literal digit separators. > >> > >> I'm not sure which GCC version to mention here. C++14 was feature-complete > >> in GCC 5, and became the default in GCC 6. 5.5.0 builds trunk with no > >> trouble, but of course trunk also doesn't use any C++14 features. Looking > >> at bugzilla, I see only one C++14 fix (PR71630) in 5.5, and it doesn't seem > >> important. In 5.4, PR69995 seems potentially significant, so shall we > >> recommend 5.4 or later? Or just say 5.5 because people are unlikely to be > >> stuck on an earlier minor release? > >> > >> gcc/ChangeLog: > >> > >> * doc/install.texi (Prerequisites): Update to C++14. > >> > >> ChangeLog: > >> > >> * configure.ac: Update requirement to C++14. > >> * configure: Regenerate. > >> --- > >> gcc/doc/install.texi | 15 +- > >> configure.ac | 12 +- > >> configure | 832 ++++++++++++++++++++++++++++++++++++++++--- > >> 3 files changed, 790 insertions(+), 69 deletions(-) > >> > >> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi > >> index e339d736969..87add0b6572 100644 > >> --- a/gcc/doc/install.texi > >> +++ b/gcc/doc/install.texi > >> @@ -222,17 +222,18 @@ described below. > >> > >> @heading Tools/packages necessary for building GCC > >> @table @asis > >> -@item ISO C++11 compiler > >> -Necessary to bootstrap GCC. GCC 4.8.3 or newer has sufficient > >> -support for used C++11 features. > >> +@item ISO C++14 compiler > >> +Necessary to bootstrap GCC. GCC 5.5 or newer has sufficient > >> +support for used C++14 features. > >> > >> -Versions of GCC prior to 11 also allow bootstrapping with an ISO C++98 > >> -compiler, and versions of GCC prior to 4.8 also allow bootstrapping with > >> -an ISO C89 compiler. > >> +Versions of GCC prior to 15 allow bootstrapping with an ISO C++11 > >> +compiler, versions prior to 11 allow bootstrapping with an ISO C++98 > >> +compiler, and versions prior to 4.8 allow bootstrapping with an ISO > >> +C89 compiler. > >> > >> To build all languages in a cross-compiler or other configuration where > >> 3-stage bootstrap is not performed, you need to start with an existing > >> -GCC binary (version 4.8.3 or later) because source code for language > >> +GCC binary (version 5.5 or later) because source code for language > >> frontends other than C might use GCC extensions. > >> > >> @item C standard library and headers > >> diff --git a/configure.ac b/configure.ac > >> index f61dbe64a94..91635d5368a 100644 > >> --- a/configure.ac > >> +++ b/configure.ac > >> @@ -1457,16 +1457,16 @@ case "$have_compiler:$host:$target:$enable_bootstrap" in > >> ;; > >> esac > >> > >> -# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a > >> -# C++11 compiler can still start the bootstrap. Otherwise, if building GCC, > >> -# require C++11 (or higher). > >> +# When bootstrapping with GCC, build stage 1 in C++14 mode to ensure that a > >> +# C++14 compiler can still start the bootstrap. Otherwise, if building GCC, > >> +# require C++14 (or higher). > >> if test "$enable_bootstrap:$GXX" = "yes:yes"; then > >> - CXX="$CXX -std=c++11" > >> + CXX="$CXX -std=c++14" > >> elif test "$have_compiler" = yes; then > >> - AX_CXX_COMPILE_STDCXX(11) > >> + AX_CXX_COMPILE_STDCXX(14) > >> > >> if test "${build}" != "${host}"; then > >> - AX_CXX_COMPILE_STDCXX(11, [], [], [_FOR_BUILD]) > >> + AX_CXX_COMPILE_STDCXX(14, [], [], [_FOR_BUILD]) > >> fi > >> fi > >> > >> diff --git a/configure b/configure > >> index e9583f2ba0c..ab9719c6e93 100755 > >> --- a/configure > >> +++ b/configure > >> @@ -712,8 +712,8 @@ gmplibs > >> PGO_BUILD_LTO_CFLAGS > >> PGO_BUILD_USE_CFLAGS > >> PGO_BUILD_GEN_CFLAGS > >> -HAVE_CXX11_FOR_BUILD > >> -HAVE_CXX11 > >> +HAVE_CXX14_FOR_BUILD > >> +HAVE_CXX14 > >> do_compare > >> CARGO > >> GDC > >> @@ -5914,13 +5914,13 @@ $as_echo "$as_me: WARNING: trying to bootstrap a cross compiler" >&2;} > >> ;; > >> esac > >> > >> -# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a > >> -# C++11 compiler can still start the bootstrap. Otherwise, if building GCC, > >> -# require C++11 (or higher). > >> +# When bootstrapping with GCC, build stage 1 in C++14 mode to ensure that a > >> +# C++14 compiler can still start the bootstrap. Otherwise, if building GCC, > >> +# require C++14 (or higher). > >> if test "$enable_bootstrap:$GXX" = "yes:yes"; then > >> - CXX="$CXX -std=c++11" > >> + CXX="$CXX -std=c++14" > >> elif test "$have_compiler" = yes; then > >> - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true > >> + ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=true > >> ac_ext=cpp > >> ac_cpp='$CXXCPP $CPPFLAGS' > >> ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' > >> @@ -5928,9 +5928,9 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex > >> ac_compiler_gnu=$ac_cv_cxx_compiler_gnu > >> ac_success=no > >> > >> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 > >> -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } > >> -if ${ax_cv_cxx_compile_cxx11+:} false; then : > >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features by default" >&5 > >> +$as_echo_n "checking whether $CXX supports C++14 features by default... " >&6; } > >> +if ${ax_cv_cxx_compile_cxx14+:} false; then : > >> $as_echo_n "(cached) " >&6 > >> else > >> cat confdefs.h - <<_ACEOF >conftest.$ac_ext > >> @@ -6223,26 +6223,146 @@ namespace cxx11 > >> > >> > >> > >> + > >> +// If the compiler admits that it is not ready for C++14, why torture it? > >> +// Hopefully, this will speed up the test. > >> + > >> +#ifndef __cplusplus > >> + > >> +#error "This is not a C++ compiler" > >> + > >> +#elif __cplusplus < 201402L > >> + > >> +#error "This is not a C++14 compiler" > >> + > >> +#else > >> + > >> +namespace cxx14 > >> +{ > >> + > >> + namespace test_polymorphic_lambdas > >> + { > >> + > >> + int > >> + test() > >> + { > >> + const auto lambda = [](auto&&... args){ > >> + const auto istiny = [](auto x){ > >> + return (sizeof(x) == 1UL) ? 1 : 0; > >> + }; > >> + const int aretiny[] = { istiny(args)... }; > >> + return aretiny[0]; > >> + }; > >> + return lambda(1, 1L, 1.0f, '1'); > >> + } > >> + > >> + } > >> + > >> + namespace test_binary_literals > >> + { > >> + > >> + constexpr auto ivii = 0b0000000000101010; > >> + static_assert(ivii == 42, "wrong value"); > >> + > >> + } > >> + > >> + namespace test_generalized_constexpr > >> + { > >> + > >> + template < typename CharT > > >> + constexpr unsigned long > >> + strlen_c(const CharT *const s) noexcept > >> + { > >> + auto length = 0UL; > >> + for (auto p = s; *p; ++p) > >> + ++length; > >> + return length; > >> + } > >> + > >> + static_assert(strlen_c("") == 0UL, ""); > >> + static_assert(strlen_c("x") == 1UL, ""); > >> + static_assert(strlen_c("test") == 4UL, ""); > >> + static_assert(strlen_c("another\0test") == 7UL, ""); > >> + > >> + } > >> + > >> + namespace test_lambda_init_capture > >> + { > >> + > >> + int > >> + test() > >> + { > >> + auto x = 0; > >> + const auto lambda1 = [a = x](int b){ return a + b; }; > >> + const auto lambda2 = [a = lambda1(x)](){ return a; }; > >> + return lambda2(); > >> + } > >> + > >> + } > >> + > >> + namespace test_digit_separators > >> + { > >> + > >> + constexpr auto ten_million = 100'000'000; > >> + static_assert(ten_million == 100000000, ""); > >> + > >> + } > >> + > >> + namespace test_return_type_deduction > >> + { > >> + > >> + auto f(int& x) { return x; } > >> + decltype(auto) g(int& x) { return x; } > >> + > >> + template < typename T1, typename T2 > > >> + struct is_same > >> + { > >> + static constexpr auto value = false; > >> + }; > >> + > >> + template < typename T > > >> + struct is_same<T, T> > >> + { > >> + static constexpr auto value = true; > >> + }; > >> + > >> + int > >> + test() > >> + { > >> + auto x = 0; > >> + static_assert(is_same<int, decltype(f(x))>::value, ""); > >> + static_assert(is_same<int&, decltype(g(x))>::value, ""); > >> + return x; > >> + } > >> + > >> + } > >> + > >> +} // namespace cxx14 > >> + > >> +#endif // __cplusplus >= 201402L > >> + > >> + > >> + > >> _ACEOF > >> if ac_fn_cxx_try_compile "$LINENO"; then : > >> - ax_cv_cxx_compile_cxx11=yes > >> + ax_cv_cxx_compile_cxx14=yes > >> else > >> - ax_cv_cxx_compile_cxx11=no > >> + ax_cv_cxx_compile_cxx14=no > >> fi > >> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > >> fi > >> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 > >> -$as_echo "$ax_cv_cxx_compile_cxx11" >&6; } > >> - if test x$ax_cv_cxx_compile_cxx11 = xyes; then > >> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx14" >&5 > >> +$as_echo "$ax_cv_cxx_compile_cxx14" >&6; } > >> + if test x$ax_cv_cxx_compile_cxx14 = xyes; then > >> ac_success=yes > >> fi > >> > >> if test x$ac_success = xno; then > >> for alternative in ${ax_cxx_compile_alternatives}; do > >> switch="-std=gnu++${alternative}" > >> - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` > >> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 > >> -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } > >> + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` > >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 > >> +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } > >> if eval \${$cachevar+:} false; then : > >> $as_echo_n "(cached) " >&6 > >> else > >> @@ -6538,6 +6658,126 @@ namespace cxx11 > >> > >> > >> > >> + > >> +// If the compiler admits that it is not ready for C++14, why torture it? > >> +// Hopefully, this will speed up the test. > >> + > >> +#ifndef __cplusplus > >> + > >> +#error "This is not a C++ compiler" > >> + > >> +#elif __cplusplus < 201402L > >> + > >> +#error "This is not a C++14 compiler" > >> + > >> +#else > >> + > >> +namespace cxx14 > >> +{ > >> + > >> + namespace test_polymorphic_lambdas > >> + { > >> + > >> + int > >> + test() > >> + { > >> + const auto lambda = [](auto&&... args){ > >> + const auto istiny = [](auto x){ > >> + return (sizeof(x) == 1UL) ? 1 : 0; > >> + }; > >> + const int aretiny[] = { istiny(args)... }; > >> + return aretiny[0]; > >> + }; > >> + return lambda(1, 1L, 1.0f, '1'); > >> + } > >> + > >> + } > >> + > >> + namespace test_binary_literals > >> + { > >> + > >> + constexpr auto ivii = 0b0000000000101010; > >> + static_assert(ivii == 42, "wrong value"); > >> + > >> + } > >> + > >> + namespace test_generalized_constexpr > >> + { > >> + > >> + template < typename CharT > > >> + constexpr unsigned long > >> + strlen_c(const CharT *const s) noexcept > >> + { > >> + auto length = 0UL; > >> + for (auto p = s; *p; ++p) > >> + ++length; > >> + return length; > >> + } > >> + > >> + static_assert(strlen_c("") == 0UL, ""); > >> + static_assert(strlen_c("x") == 1UL, ""); > >> + static_assert(strlen_c("test") == 4UL, ""); > >> + static_assert(strlen_c("another\0test") == 7UL, ""); > >> + > >> + } > >> + > >> + namespace test_lambda_init_capture > >> + { > >> + > >> + int > >> + test() > >> + { > >> + auto x = 0; > >> + const auto lambda1 = [a = x](int b){ return a + b; }; > >> + const auto lambda2 = [a = lambda1(x)](){ return a; }; > >> + return lambda2(); > >> + } > >> + > >> + } > >> + > >> + namespace test_digit_separators > >> + { > >> + > >> + constexpr auto ten_million = 100'000'000; > >> + static_assert(ten_million == 100000000, ""); > >> + > >> + } > >> + > >> + namespace test_return_type_deduction > >> + { > >> + > >> + auto f(int& x) { return x; } > >> + decltype(auto) g(int& x) { return x; } > >> + > >> + template < typename T1, typename T2 > > >> + struct is_same > >> + { > >> + static constexpr auto value = false; > >> + }; > >> + > >> + template < typename T > > >> + struct is_same<T, T> > >> + { > >> + static constexpr auto value = true; > >> + }; > >> + > >> + int > >> + test() > >> + { > >> + auto x = 0; > >> + static_assert(is_same<int, decltype(f(x))>::value, ""); > >> + static_assert(is_same<int&, decltype(g(x))>::value, ""); > >> + return x; > >> + } > >> + > >> + } > >> + > >> +} // namespace cxx14 > >> + > >> +#endif // __cplusplus >= 201402L > >> + > >> + > >> + > >> _ACEOF > >> if ac_fn_cxx_try_compile "$LINENO"; then : > >> eval $cachevar=yes > >> @@ -6564,9 +6804,9 @@ $as_echo "$ac_res" >&6; } > >> if test x$ac_success = xno; then > >> for alternative in ${ax_cxx_compile_alternatives}; do > >> for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do > >> - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` > >> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 > >> -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } > >> + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` > >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 > >> +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } > >> if eval \${$cachevar+:} false; then : > >> $as_echo_n "(cached) " >&6 > >> else > >> @@ -6862,6 +7102,126 @@ namespace cxx11 > >> > >> > >> > >> + > >> +// If the compiler admits that it is not ready for C++14, why torture it? > >> +// Hopefully, this will speed up the test. > >> + > >> +#ifndef __cplusplus > >> + > >> +#error "This is not a C++ compiler" > >> + > >> +#elif __cplusplus < 201402L > >> + > >> +#error "This is not a C++14 compiler" > >> + > >> +#else > >> + > >> +namespace cxx14 > >> +{ > >> + > >> + namespace test_polymorphic_lambdas > >> + { > >> + > >> + int > >> + test() > >> + { > >> + const auto lambda = [](auto&&... args){ > >> + const auto istiny = [](auto x){ > >> + return (sizeof(x) == 1UL) ? 1 : 0; > >> + }; > >> + const int aretiny[] = { istiny(args)... }; > >> + return aretiny[0]; > >> + }; > >> + return lambda(1, 1L, 1.0f, '1'); > >> + } > >> + > >> + } > >> + > >> + namespace test_binary_literals > >> + { > >> + > >> + constexpr auto ivii = 0b0000000000101010; > >> + static_assert(ivii == 42, "wrong value"); > >> + > >> + } > >> + > >> + namespace test_generalized_constexpr > >> + { > >> + > >> + template < typename CharT > > >> + constexpr unsigned long > >> + strlen_c(const CharT *const s) noexcept > >> + { > >> + auto length = 0UL; > >> + for (auto p = s; *p; ++p) > >> + ++length; > >> + return length; > >> + } > >> + > >> + static_assert(strlen_c("") == 0UL, ""); > >> + static_assert(strlen_c("x") == 1UL, ""); > >> + static_assert(strlen_c("test") == 4UL, ""); > >> + static_assert(strlen_c("another\0test") == 7UL, ""); > >> + > >> + } > >> + > >> + namespace test_lambda_init_capture > >> + { > >> + > >> + int > >> + test() > >> + { > >> + auto x = 0; > >> + const auto lambda1 = [a = x](int b){ return a + b; }; > >> + const auto lambda2 = [a = lambda1(x)](){ return a; }; > >> + return lambda2(); > >> + } > >> + > >> + } > >> + > >> + namespace test_digit_separators > >> + { > >> + > >> + constexpr auto ten_million = 100'000'000; > >> + static_assert(ten_million == 100000000, ""); > >> + > >> + } > >> + > >> + namespace test_return_type_deduction > >> + { > >> + > >> + auto f(int& x) { return x; } > >> + decltype(auto) g(int& x) { return x; } > >> + > >> + template < typename T1, typename T2 > > >> + struct is_same > >> + { > >> + static constexpr auto value = false; > >> + }; > >> + > >> + template < typename T > > >> + struct is_same<T, T> > >> + { > >> + static constexpr auto value = true; > >> + }; > >> + > >> + int > >> + test() > >> + { > >> + auto x = 0; > >> + static_assert(is_same<int, decltype(f(x))>::value, ""); > >> + static_assert(is_same<int&, decltype(g(x))>::value, ""); > >> + return x; > >> + } > >> + > >> + } > >> + > >> +} // namespace cxx14 > >> + > >> +#endif // __cplusplus >= 201402L > >> + > >> + > >> + > >> _ACEOF > >> if ac_fn_cxx_try_compile "$LINENO"; then : > >> eval $cachevar=yes > >> @@ -6895,41 +7255,41 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' > >> ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' > >> ac_compiler_gnu=$ac_cv_c_compiler_gnu > >> > >> - if test x$ax_cxx_compile_cxx11_required = xtrue; then > >> + if test x$ax_cxx_compile_cxx14_required = xtrue; then > >> if test x$ac_success = xno; then > >> - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 > >> + as_fn_error $? "*** A compiler with support for C++14 language features is required." "$LINENO" 5 > >> fi > >> fi > >> if test x$ac_success = xno; then > >> - HAVE_CXX11=0 > >> - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 > >> -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} > >> + HAVE_CXX14=0 > >> + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++14 support was found" >&5 > >> +$as_echo "$as_me: No compiler with C++14 support was found" >&6;} > >> else > >> - HAVE_CXX11=1 > >> + HAVE_CXX14=1 > >> > >> -$as_echo "#define HAVE_CXX11 1" >>confdefs.h > >> +$as_echo "#define HAVE_CXX14 1" >>confdefs.h > >> > >> fi > >> > >> > >> > >> if test "${build}" != "${host}"; then > >> - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true > >> + ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=true > >> ac_ext=cpp > >> ac_cpp='$CXXCPP $CPPFLAGS' > >> ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' > >> ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' > >> ac_compiler_gnu=$ac_cv_cxx_compiler_gnu > >> ac_success=no > >> - ax_cv_cxx_compile_cxx11_orig_cxx="$CXX" > >> - ax_cv_cxx_compile_cxx11_orig_cxxflags="$CXXFLAGS" > >> - ax_cv_cxx_compile_cxx11_orig_cppflags="$CPPFLAGS" > >> + ax_cv_cxx_compile_cxx14_orig_cxx="$CXX" > >> + ax_cv_cxx_compile_cxx14_orig_cxxflags="$CXXFLAGS" > >> + ax_cv_cxx_compile_cxx14_orig_cppflags="$CPPFLAGS" > >> CXX="$CXX_FOR_BUILD" > >> CXXFLAGS="$CXXFLAGS_FOR_BUILD" > >> CPPFLAGS="$CPPFLAGS_FOR_BUILD" > >> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 > >> -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } > >> -if ${ax_cv_cxx_compile_cxx11_FOR_BUILD+:} false; then : > >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features by default" >&5 > >> +$as_echo_n "checking whether $CXX supports C++14 features by default... " >&6; } > >> +if ${ax_cv_cxx_compile_cxx14_FOR_BUILD+:} false; then : > >> $as_echo_n "(cached) " >&6 > >> else > >> cat confdefs.h - <<_ACEOF >conftest.$ac_ext > >> @@ -7222,26 +7582,146 @@ namespace cxx11 > >> > >> > >> > >> + > >> +// If the compiler admits that it is not ready for C++14, why torture it? > >> +// Hopefully, this will speed up the test. > >> + > >> +#ifndef __cplusplus > >> + > >> +#error "This is not a C++ compiler" > >> + > >> +#elif __cplusplus < 201402L > >> + > >> +#error "This is not a C++14 compiler" > >> + > >> +#else > >> + > >> +namespace cxx14 > >> +{ > >> + > >> + namespace test_polymorphic_lambdas > >> + { > >> + > >> + int > >> + test() > >> + { > >> + const auto lambda = [](auto&&... args){ > >> + const auto istiny = [](auto x){ > >> + return (sizeof(x) == 1UL) ? 1 : 0; > >> + }; > >> + const int aretiny[] = { istiny(args)... }; > >> + return aretiny[0]; > >> + }; > >> + return lambda(1, 1L, 1.0f, '1'); > >> + } > >> + > >> + } > >> + > >> + namespace test_binary_literals > >> + { > >> + > >> + constexpr auto ivii = 0b0000000000101010; > >> + static_assert(ivii == 42, "wrong value"); > >> + > >> + } > >> + > >> + namespace test_generalized_constexpr > >> + { > >> + > >> + template < typename CharT > > >> + constexpr unsigned long > >> + strlen_c(const CharT *const s) noexcept > >> + { > >> + auto length = 0UL; > >> + for (auto p = s; *p; ++p) > >> + ++length; > >> + return length; > >> + } > >> + > >> + static_assert(strlen_c("") == 0UL, ""); > >> + static_assert(strlen_c("x") == 1UL, ""); > >> + static_assert(strlen_c("test") == 4UL, ""); > >> + static_assert(strlen_c("another\0test") == 7UL, ""); > >> + > >> + } > >> + > >> + namespace test_lambda_init_capture > >> + { > >> + > >> + int > >> + test() > >> + { > >> + auto x = 0; > >> + const auto lambda1 = [a = x](int b){ return a + b; }; > >> + const auto lambda2 = [a = lambda1(x)](){ return a; }; > >> + return lambda2(); > >> + } > >> + > >> + } > >> + > >> + namespace test_digit_separators > >> + { > >> + > >> + constexpr auto ten_million = 100'000'000; > >> + static_assert(ten_million == 100000000, ""); > >> + > >> + } > >> + > >> + namespace test_return_type_deduction > >> + { > >> + > >> + auto f(int& x) { return x; } > >> + decltype(auto) g(int& x) { return x; } > >> + > >> + template < typename T1, typename T2 > > >> + struct is_same > >> + { > >> + static constexpr auto value = false; > >> + }; > >> + > >> + template < typename T > > >> + struct is_same<T, T> > >> + { > >> + static constexpr auto value = true; > >> + }; > >> + > >> + int > >> + test() > >> + { > >> + auto x = 0; > >> + static_assert(is_same<int, decltype(f(x))>::value, ""); > >> + static_assert(is_same<int&, decltype(g(x))>::value, ""); > >> + return x; > >> + } > >> + > >> + } > >> + > >> +} // namespace cxx14 > >> + > >> +#endif // __cplusplus >= 201402L > >> + > >> + > >> + > >> _ACEOF > >> if ac_fn_cxx_try_compile "$LINENO"; then : > >> - ax_cv_cxx_compile_cxx11_FOR_BUILD=yes > >> + ax_cv_cxx_compile_cxx14_FOR_BUILD=yes > >> else > >> - ax_cv_cxx_compile_cxx11_FOR_BUILD=no > >> + ax_cv_cxx_compile_cxx14_FOR_BUILD=no > >> fi > >> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > >> fi > >> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11_FOR_BUILD" >&5 > >> -$as_echo "$ax_cv_cxx_compile_cxx11_FOR_BUILD" >&6; } > >> - if test x$ax_cv_cxx_compile_cxx11_FOR_BUILD = xyes; then > >> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx14_FOR_BUILD" >&5 > >> +$as_echo "$ax_cv_cxx_compile_cxx14_FOR_BUILD" >&6; } > >> + if test x$ax_cv_cxx_compile_cxx14_FOR_BUILD = xyes; then > >> ac_success=yes > >> fi > >> > >> if test x$ac_success = xno; then > >> for alternative in ${ax_cxx_compile_alternatives}; do > >> switch="-std=gnu++${alternative}" > >> - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_FOR_BUILD_$switch" | $as_tr_sh` > >> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 > >> -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } > >> + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_FOR_BUILD_$switch" | $as_tr_sh` > >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 > >> +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } > >> if eval \${$cachevar+:} false; then : > >> $as_echo_n "(cached) " >&6 > >> else > >> @@ -7537,6 +8017,126 @@ namespace cxx11 > >> > >> > >> > >> + > >> +// If the compiler admits that it is not ready for C++14, why torture it? > >> +// Hopefully, this will speed up the test. > >> + > >> +#ifndef __cplusplus > >> + > >> +#error "This is not a C++ compiler" > >> + > >> +#elif __cplusplus < 201402L > >> + > >> +#error "This is not a C++14 compiler" > >> + > >> +#else > >> + > >> +namespace cxx14 > >> +{ > >> + > >> + namespace test_polymorphic_lambdas > >> + { > >> + > >> + int > >> + test() > >> + { > >> + const auto lambda = [](auto&&... args){ > >> + const auto istiny = [](auto x){ > >> + return (sizeof(x) == 1UL) ? 1 : 0; > >> + }; > >> + const int aretiny[] = { istiny(args)... }; > >> + return aretiny[0]; > >> + }; > >> + return lambda(1, 1L, 1.0f, '1'); > >> + } > >> + > >> + } > >> + > >> + namespace test_binary_literals > >> + { > >> + > >> + constexpr auto ivii = 0b0000000000101010; > >> + static_assert(ivii == 42, "wrong value"); > >> + > >> + } > >> + > >> + namespace test_generalized_constexpr > >> + { > >> + > >> + template < typename CharT > > >> + constexpr unsigned long > >> + strlen_c(const CharT *const s) noexcept > >> + { > >> + auto length = 0UL; > >> + for (auto p = s; *p; ++p) > >> + ++length; > >> + return length; > >> + } > >> + > >> + static_assert(strlen_c("") == 0UL, ""); > >> + static_assert(strlen_c("x") == 1UL, ""); > >> + static_assert(strlen_c("test") == 4UL, ""); > >> + static_assert(strlen_c("another\0test") == 7UL, ""); > >> + > >> + } > >> + > >> + namespace test_lambda_init_capture > >> + { > >> + > >> + int > >> + test() > >> + { > >> + auto x = 0; > >> + const auto lambda1 = [a = x](int b){ return a + b; }; > >> + const auto lambda2 = [a = lambda1(x)](){ return a; }; > >> + return lambda2(); > >> + } > >> + > >> + } > >> + > >> + namespace test_digit_separators > >> + { > >> + > >> + constexpr auto ten_million = 100'000'000; > >> + static_assert(ten_million == 100000000, ""); > >> + > >> + } > >> + > >> + namespace test_return_type_deduction > >> + { > >> + > >> + auto f(int& x) { return x; } > >> + decltype(auto) g(int& x) { return x; } > >> + > >> + template < typename T1, typename T2 > > >> + struct is_same > >> + { > >> + static constexpr auto value = false; > >> + }; > >> + > >> + template < typename T > > >> + struct is_same<T, T> > >> + { > >> + static constexpr auto value = true; > >> + }; > >> + > >> + int > >> + test() > >> + { > >> + auto x = 0; > >> + static_assert(is_same<int, decltype(f(x))>::value, ""); > >> + static_assert(is_same<int&, decltype(g(x))>::value, ""); > >> + return x; > >> + } > >> + > >> + } > >> + > >> +} // namespace cxx14 > >> + > >> +#endif // __cplusplus >= 201402L > >> + > >> + > >> + > >> _ACEOF > >> if ac_fn_cxx_try_compile "$LINENO"; then : > >> eval $cachevar=yes > >> @@ -7563,9 +8163,9 @@ $as_echo "$ac_res" >&6; } > >> if test x$ac_success = xno; then > >> for alternative in ${ax_cxx_compile_alternatives}; do > >> for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do > >> - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_FOR_BUILD_$switch" | $as_tr_sh` > >> - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 > >> -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } > >> + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_FOR_BUILD_$switch" | $as_tr_sh` > >> + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 > >> +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } > >> if eval \${$cachevar+:} false; then : > >> $as_echo_n "(cached) " >&6 > >> else > >> @@ -7861,6 +8461,126 @@ namespace cxx11 > >> > >> > >> > >> + > >> +// If the compiler admits that it is not ready for C++14, why torture it? > >> +// Hopefully, this will speed up the test. > >> + > >> +#ifndef __cplusplus > >> + > >> +#error "This is not a C++ compiler" > >> + > >> +#elif __cplusplus < 201402L > >> + > >> +#error "This is not a C++14 compiler" > >> + > >> +#else > >> + > >> +namespace cxx14 > >> +{ > >> + > >> + namespace test_polymorphic_lambdas > >> + { > >> + > >> + int > >> + test() > >> + { > >> + const auto lambda = [](auto&&... args){ > >> + const auto istiny = [](auto x){ > >> + return (sizeof(x) == 1UL) ? 1 : 0; > >> + }; > >> + const int aretiny[] = { istiny(args)... }; > >> + return aretiny[0]; > >> + }; > >> + return lambda(1, 1L, 1.0f, '1'); > >> + } > >> + > >> + } > >> + > >> + namespace test_binary_literals > >> + { > >> + > >> + constexpr auto ivii = 0b0000000000101010; > >> + static_assert(ivii == 42, "wrong value"); > >> + > >> + } > >> + > >> + namespace test_generalized_constexpr > >> + { > >> + > >> + template < typename CharT > > >> + constexpr unsigned long > >> + strlen_c(const CharT *const s) noexcept > >> + { > >> + auto length = 0UL; > >> + for (auto p = s; *p; ++p) > >> + ++length; > >> + return length; > >> + } > >> + > >> + static_assert(strlen_c("") == 0UL, ""); > >> + static_assert(strlen_c("x") == 1UL, ""); > >> + static_assert(strlen_c("test") == 4UL, ""); > >> + static_assert(strlen_c("another\0test") == 7UL, ""); > >> + > >> + } > >> + > >> + namespace test_lambda_init_capture > >> + { > >> + > >> + int > >> + test() > >> + { > >> + auto x = 0; > >> + const auto lambda1 = [a = x](int b){ return a + b; }; > >> + const auto lambda2 = [a = lambda1(x)](){ return a; }; > >> + return lambda2(); > >> + } > >> + > >> + } > >> + > >> + namespace test_digit_separators > >> + { > >> + > >> + constexpr auto ten_million = 100'000'000; > >> + static_assert(ten_million == 100000000, ""); > >> + > >> + } > >> + > >> + namespace test_return_type_deduction > >> + { > >> + > >> + auto f(int& x) { return x; } > >> + decltype(auto) g(int& x) { return x; } > >> + > >> + template < typename T1, typename T2 > > >> + struct is_same > >> + { > >> + static constexpr auto value = false; > >> + }; > >> + > >> + template < typename T > > >> + struct is_same<T, T> > >> + { > >> + static constexpr auto value = true; > >> + }; > >> + > >> + int > >> + test() > >> + { > >> + auto x = 0; > >> + static_assert(is_same<int, decltype(f(x))>::value, ""); > >> + static_assert(is_same<int&, decltype(g(x))>::value, ""); > >> + return x; > >> + } > >> + > >> + } > >> + > >> +} // namespace cxx14 > >> + > >> +#endif // __cplusplus >= 201402L > >> + > >> + > >> + > >> _ACEOF > >> if ac_fn_cxx_try_compile "$LINENO"; then : > >> eval $cachevar=yes > >> @@ -7890,28 +8610,28 @@ $as_echo "$ac_res" >&6; } > >> CXX_FOR_BUILD="$CXX" > >> CXXFLAGS_FOR_BUILD="$CXXFLAGS" > >> CPPFLAGS_FOR_BUILD="$CPPFLAGS" > >> - CXX="$ax_cv_cxx_compile_cxx11_orig_cxx" > >> - CXXFLAGS="$ax_cv_cxx_compile_cxx11_orig_cxxflags" > >> - CPPFLAGS="$ax_cv_cxx_compile_cxx11_orig_cppflags" > >> + CXX="$ax_cv_cxx_compile_cxx14_orig_cxx" > >> + CXXFLAGS="$ax_cv_cxx_compile_cxx14_orig_cxxflags" > >> + CPPFLAGS="$ax_cv_cxx_compile_cxx14_orig_cppflags" > >> ac_ext=c > >> ac_cpp='$CPP $CPPFLAGS' > >> ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' > >> ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' > >> ac_compiler_gnu=$ac_cv_c_compiler_gnu > >> > >> - if test x$ax_cxx_compile_cxx11_required = xtrue; then > >> + if test x$ax_cxx_compile_cxx14_required = xtrue; then > >> if test x$ac_success = xno; then > >> - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 > >> + as_fn_error $? "*** A compiler with support for C++14 language features is required." "$LINENO" 5 > >> fi > >> fi > >> if test x$ac_success = xno; then > >> - HAVE_CXX11_FOR_BUILD=0 > >> - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 > >> -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} > >> + HAVE_CXX14_FOR_BUILD=0 > >> + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++14 support was found" >&5 > >> +$as_echo "$as_me: No compiler with C++14 support was found" >&6;} > >> else > >> - HAVE_CXX11_FOR_BUILD=1 > >> + HAVE_CXX14_FOR_BUILD=1 > >> > >> -$as_echo "#define HAVE_CXX11_FOR_BUILD 1" >>confdefs.h > >> +$as_echo "#define HAVE_CXX14_FOR_BUILD 1" >>confdefs.h > >> > >> fi > >> > >> > >> base-commit: 5c8f9f4d4cebabf85e68c5bdbe2d4ee6646edc7c > >> -- > >> 2.46.0 > >> > > >
On Wed, Sep 18, 2024 at 6:22 PM Jason Merrill <jason@redhat.com> wrote: > > Tested x86_64-pc-linux-gnu with 5.5.0 bootstrap compiler. Thoughts? I'm fine with this in general - do we have needs of bumping the requirement for GCC 15 though? IMO we should bump once we are requiring actual C++14 in some place. As of the version requirement as you say only some minor versions of the GCC 5 series are OK I would suggest to say we recommend using GCC 6 or later but GCC 5.5 should also work? Richard. > -- 8< -- > > This implements my proposal to update our bootstrap requirement to C++14. > The big benefit of the change is the greater constexpr power, but C++14 also > added variable templates, generic lambdas, lambda init-capture, binary > literals, and numeric literal digit separators. > > I'm not sure which GCC version to mention here. C++14 was feature-complete > in GCC 5, and became the default in GCC 6. 5.5.0 builds trunk with no > trouble, but of course trunk also doesn't use any C++14 features. Looking > at bugzilla, I see only one C++14 fix (PR71630) in 5.5, and it doesn't seem > important. In 5.4, PR69995 seems potentially significant, so shall we > recommend 5.4 or later? Or just say 5.5 because people are unlikely to be > stuck on an earlier minor release? > > gcc/ChangeLog: > > * doc/install.texi (Prerequisites): Update to C++14. > > ChangeLog: > > * configure.ac: Update requirement to C++14. > * configure: Regenerate. > --- > gcc/doc/install.texi | 15 +- > configure.ac | 12 +- > configure | 832 ++++++++++++++++++++++++++++++++++++++++--- > 3 files changed, 790 insertions(+), 69 deletions(-) > > diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi > index e339d736969..87add0b6572 100644 > --- a/gcc/doc/install.texi > +++ b/gcc/doc/install.texi > @@ -222,17 +222,18 @@ described below. > > @heading Tools/packages necessary for building GCC > @table @asis > -@item ISO C++11 compiler > -Necessary to bootstrap GCC. GCC 4.8.3 or newer has sufficient > -support for used C++11 features. > +@item ISO C++14 compiler > +Necessary to bootstrap GCC. GCC 5.5 or newer has sufficient > +support for used C++14 features. > > -Versions of GCC prior to 11 also allow bootstrapping with an ISO C++98 > -compiler, and versions of GCC prior to 4.8 also allow bootstrapping with > -an ISO C89 compiler. > +Versions of GCC prior to 15 allow bootstrapping with an ISO C++11 > +compiler, versions prior to 11 allow bootstrapping with an ISO C++98 > +compiler, and versions prior to 4.8 allow bootstrapping with an ISO > +C89 compiler. > > To build all languages in a cross-compiler or other configuration where > 3-stage bootstrap is not performed, you need to start with an existing > -GCC binary (version 4.8.3 or later) because source code for language > +GCC binary (version 5.5 or later) because source code for language > frontends other than C might use GCC extensions. > > @item C standard library and headers > diff --git a/configure.ac b/configure.ac > index f61dbe64a94..91635d5368a 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -1457,16 +1457,16 @@ case "$have_compiler:$host:$target:$enable_bootstrap" in > ;; > esac > > -# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a > -# C++11 compiler can still start the bootstrap. Otherwise, if building GCC, > -# require C++11 (or higher). > +# When bootstrapping with GCC, build stage 1 in C++14 mode to ensure that a > +# C++14 compiler can still start the bootstrap. Otherwise, if building GCC, > +# require C++14 (or higher). > if test "$enable_bootstrap:$GXX" = "yes:yes"; then > - CXX="$CXX -std=c++11" > + CXX="$CXX -std=c++14" > elif test "$have_compiler" = yes; then > - AX_CXX_COMPILE_STDCXX(11) > + AX_CXX_COMPILE_STDCXX(14) > > if test "${build}" != "${host}"; then > - AX_CXX_COMPILE_STDCXX(11, [], [], [_FOR_BUILD]) > + AX_CXX_COMPILE_STDCXX(14, [], [], [_FOR_BUILD]) > fi > fi > > diff --git a/configure b/configure > index e9583f2ba0c..ab9719c6e93 100755 > --- a/configure > +++ b/configure > @@ -712,8 +712,8 @@ gmplibs > PGO_BUILD_LTO_CFLAGS > PGO_BUILD_USE_CFLAGS > PGO_BUILD_GEN_CFLAGS > -HAVE_CXX11_FOR_BUILD > -HAVE_CXX11 > +HAVE_CXX14_FOR_BUILD > +HAVE_CXX14 > do_compare > CARGO > GDC > @@ -5914,13 +5914,13 @@ $as_echo "$as_me: WARNING: trying to bootstrap a cross compiler" >&2;} > ;; > esac > > -# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a > -# C++11 compiler can still start the bootstrap. Otherwise, if building GCC, > -# require C++11 (or higher). > +# When bootstrapping with GCC, build stage 1 in C++14 mode to ensure that a > +# C++14 compiler can still start the bootstrap. Otherwise, if building GCC, > +# require C++14 (or higher). > if test "$enable_bootstrap:$GXX" = "yes:yes"; then > - CXX="$CXX -std=c++11" > + CXX="$CXX -std=c++14" > elif test "$have_compiler" = yes; then > - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true > + ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=true > ac_ext=cpp > ac_cpp='$CXXCPP $CPPFLAGS' > ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' > @@ -5928,9 +5928,9 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex > ac_compiler_gnu=$ac_cv_cxx_compiler_gnu > ac_success=no > > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 > -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } > -if ${ax_cv_cxx_compile_cxx11+:} false; then : > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features by default" >&5 > +$as_echo_n "checking whether $CXX supports C++14 features by default... " >&6; } > +if ${ax_cv_cxx_compile_cxx14+:} false; then : > $as_echo_n "(cached) " >&6 > else > cat confdefs.h - <<_ACEOF >conftest.$ac_ext > @@ -6223,26 +6223,146 @@ namespace cxx11 > > > > + > +// If the compiler admits that it is not ready for C++14, why torture it? > +// Hopefully, this will speed up the test. > + > +#ifndef __cplusplus > + > +#error "This is not a C++ compiler" > + > +#elif __cplusplus < 201402L > + > +#error "This is not a C++14 compiler" > + > +#else > + > +namespace cxx14 > +{ > + > + namespace test_polymorphic_lambdas > + { > + > + int > + test() > + { > + const auto lambda = [](auto&&... args){ > + const auto istiny = [](auto x){ > + return (sizeof(x) == 1UL) ? 1 : 0; > + }; > + const int aretiny[] = { istiny(args)... }; > + return aretiny[0]; > + }; > + return lambda(1, 1L, 1.0f, '1'); > + } > + > + } > + > + namespace test_binary_literals > + { > + > + constexpr auto ivii = 0b0000000000101010; > + static_assert(ivii == 42, "wrong value"); > + > + } > + > + namespace test_generalized_constexpr > + { > + > + template < typename CharT > > + constexpr unsigned long > + strlen_c(const CharT *const s) noexcept > + { > + auto length = 0UL; > + for (auto p = s; *p; ++p) > + ++length; > + return length; > + } > + > + static_assert(strlen_c("") == 0UL, ""); > + static_assert(strlen_c("x") == 1UL, ""); > + static_assert(strlen_c("test") == 4UL, ""); > + static_assert(strlen_c("another\0test") == 7UL, ""); > + > + } > + > + namespace test_lambda_init_capture > + { > + > + int > + test() > + { > + auto x = 0; > + const auto lambda1 = [a = x](int b){ return a + b; }; > + const auto lambda2 = [a = lambda1(x)](){ return a; }; > + return lambda2(); > + } > + > + } > + > + namespace test_digit_separators > + { > + > + constexpr auto ten_million = 100'000'000; > + static_assert(ten_million == 100000000, ""); > + > + } > + > + namespace test_return_type_deduction > + { > + > + auto f(int& x) { return x; } > + decltype(auto) g(int& x) { return x; } > + > + template < typename T1, typename T2 > > + struct is_same > + { > + static constexpr auto value = false; > + }; > + > + template < typename T > > + struct is_same<T, T> > + { > + static constexpr auto value = true; > + }; > + > + int > + test() > + { > + auto x = 0; > + static_assert(is_same<int, decltype(f(x))>::value, ""); > + static_assert(is_same<int&, decltype(g(x))>::value, ""); > + return x; > + } > + > + } > + > +} // namespace cxx14 > + > +#endif // __cplusplus >= 201402L > + > + > + > _ACEOF > if ac_fn_cxx_try_compile "$LINENO"; then : > - ax_cv_cxx_compile_cxx11=yes > + ax_cv_cxx_compile_cxx14=yes > else > - ax_cv_cxx_compile_cxx11=no > + ax_cv_cxx_compile_cxx14=no > fi > rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > fi > -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 > -$as_echo "$ax_cv_cxx_compile_cxx11" >&6; } > - if test x$ax_cv_cxx_compile_cxx11 = xyes; then > +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx14" >&5 > +$as_echo "$ax_cv_cxx_compile_cxx14" >&6; } > + if test x$ax_cv_cxx_compile_cxx14 = xyes; then > ac_success=yes > fi > > if test x$ac_success = xno; then > for alternative in ${ax_cxx_compile_alternatives}; do > switch="-std=gnu++${alternative}" > - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 > -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } > + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 > +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } > if eval \${$cachevar+:} false; then : > $as_echo_n "(cached) " >&6 > else > @@ -6538,6 +6658,126 @@ namespace cxx11 > > > > + > +// If the compiler admits that it is not ready for C++14, why torture it? > +// Hopefully, this will speed up the test. > + > +#ifndef __cplusplus > + > +#error "This is not a C++ compiler" > + > +#elif __cplusplus < 201402L > + > +#error "This is not a C++14 compiler" > + > +#else > + > +namespace cxx14 > +{ > + > + namespace test_polymorphic_lambdas > + { > + > + int > + test() > + { > + const auto lambda = [](auto&&... args){ > + const auto istiny = [](auto x){ > + return (sizeof(x) == 1UL) ? 1 : 0; > + }; > + const int aretiny[] = { istiny(args)... }; > + return aretiny[0]; > + }; > + return lambda(1, 1L, 1.0f, '1'); > + } > + > + } > + > + namespace test_binary_literals > + { > + > + constexpr auto ivii = 0b0000000000101010; > + static_assert(ivii == 42, "wrong value"); > + > + } > + > + namespace test_generalized_constexpr > + { > + > + template < typename CharT > > + constexpr unsigned long > + strlen_c(const CharT *const s) noexcept > + { > + auto length = 0UL; > + for (auto p = s; *p; ++p) > + ++length; > + return length; > + } > + > + static_assert(strlen_c("") == 0UL, ""); > + static_assert(strlen_c("x") == 1UL, ""); > + static_assert(strlen_c("test") == 4UL, ""); > + static_assert(strlen_c("another\0test") == 7UL, ""); > + > + } > + > + namespace test_lambda_init_capture > + { > + > + int > + test() > + { > + auto x = 0; > + const auto lambda1 = [a = x](int b){ return a + b; }; > + const auto lambda2 = [a = lambda1(x)](){ return a; }; > + return lambda2(); > + } > + > + } > + > + namespace test_digit_separators > + { > + > + constexpr auto ten_million = 100'000'000; > + static_assert(ten_million == 100000000, ""); > + > + } > + > + namespace test_return_type_deduction > + { > + > + auto f(int& x) { return x; } > + decltype(auto) g(int& x) { return x; } > + > + template < typename T1, typename T2 > > + struct is_same > + { > + static constexpr auto value = false; > + }; > + > + template < typename T > > + struct is_same<T, T> > + { > + static constexpr auto value = true; > + }; > + > + int > + test() > + { > + auto x = 0; > + static_assert(is_same<int, decltype(f(x))>::value, ""); > + static_assert(is_same<int&, decltype(g(x))>::value, ""); > + return x; > + } > + > + } > + > +} // namespace cxx14 > + > +#endif // __cplusplus >= 201402L > + > + > + > _ACEOF > if ac_fn_cxx_try_compile "$LINENO"; then : > eval $cachevar=yes > @@ -6564,9 +6804,9 @@ $as_echo "$ac_res" >&6; } > if test x$ac_success = xno; then > for alternative in ${ax_cxx_compile_alternatives}; do > for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do > - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 > -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } > + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 > +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } > if eval \${$cachevar+:} false; then : > $as_echo_n "(cached) " >&6 > else > @@ -6862,6 +7102,126 @@ namespace cxx11 > > > > + > +// If the compiler admits that it is not ready for C++14, why torture it? > +// Hopefully, this will speed up the test. > + > +#ifndef __cplusplus > + > +#error "This is not a C++ compiler" > + > +#elif __cplusplus < 201402L > + > +#error "This is not a C++14 compiler" > + > +#else > + > +namespace cxx14 > +{ > + > + namespace test_polymorphic_lambdas > + { > + > + int > + test() > + { > + const auto lambda = [](auto&&... args){ > + const auto istiny = [](auto x){ > + return (sizeof(x) == 1UL) ? 1 : 0; > + }; > + const int aretiny[] = { istiny(args)... }; > + return aretiny[0]; > + }; > + return lambda(1, 1L, 1.0f, '1'); > + } > + > + } > + > + namespace test_binary_literals > + { > + > + constexpr auto ivii = 0b0000000000101010; > + static_assert(ivii == 42, "wrong value"); > + > + } > + > + namespace test_generalized_constexpr > + { > + > + template < typename CharT > > + constexpr unsigned long > + strlen_c(const CharT *const s) noexcept > + { > + auto length = 0UL; > + for (auto p = s; *p; ++p) > + ++length; > + return length; > + } > + > + static_assert(strlen_c("") == 0UL, ""); > + static_assert(strlen_c("x") == 1UL, ""); > + static_assert(strlen_c("test") == 4UL, ""); > + static_assert(strlen_c("another\0test") == 7UL, ""); > + > + } > + > + namespace test_lambda_init_capture > + { > + > + int > + test() > + { > + auto x = 0; > + const auto lambda1 = [a = x](int b){ return a + b; }; > + const auto lambda2 = [a = lambda1(x)](){ return a; }; > + return lambda2(); > + } > + > + } > + > + namespace test_digit_separators > + { > + > + constexpr auto ten_million = 100'000'000; > + static_assert(ten_million == 100000000, ""); > + > + } > + > + namespace test_return_type_deduction > + { > + > + auto f(int& x) { return x; } > + decltype(auto) g(int& x) { return x; } > + > + template < typename T1, typename T2 > > + struct is_same > + { > + static constexpr auto value = false; > + }; > + > + template < typename T > > + struct is_same<T, T> > + { > + static constexpr auto value = true; > + }; > + > + int > + test() > + { > + auto x = 0; > + static_assert(is_same<int, decltype(f(x))>::value, ""); > + static_assert(is_same<int&, decltype(g(x))>::value, ""); > + return x; > + } > + > + } > + > +} // namespace cxx14 > + > +#endif // __cplusplus >= 201402L > + > + > + > _ACEOF > if ac_fn_cxx_try_compile "$LINENO"; then : > eval $cachevar=yes > @@ -6895,41 +7255,41 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' > ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' > ac_compiler_gnu=$ac_cv_c_compiler_gnu > > - if test x$ax_cxx_compile_cxx11_required = xtrue; then > + if test x$ax_cxx_compile_cxx14_required = xtrue; then > if test x$ac_success = xno; then > - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 > + as_fn_error $? "*** A compiler with support for C++14 language features is required." "$LINENO" 5 > fi > fi > if test x$ac_success = xno; then > - HAVE_CXX11=0 > - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 > -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} > + HAVE_CXX14=0 > + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++14 support was found" >&5 > +$as_echo "$as_me: No compiler with C++14 support was found" >&6;} > else > - HAVE_CXX11=1 > + HAVE_CXX14=1 > > -$as_echo "#define HAVE_CXX11 1" >>confdefs.h > +$as_echo "#define HAVE_CXX14 1" >>confdefs.h > > fi > > > > if test "${build}" != "${host}"; then > - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true > + ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=true > ac_ext=cpp > ac_cpp='$CXXCPP $CPPFLAGS' > ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' > ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' > ac_compiler_gnu=$ac_cv_cxx_compiler_gnu > ac_success=no > - ax_cv_cxx_compile_cxx11_orig_cxx="$CXX" > - ax_cv_cxx_compile_cxx11_orig_cxxflags="$CXXFLAGS" > - ax_cv_cxx_compile_cxx11_orig_cppflags="$CPPFLAGS" > + ax_cv_cxx_compile_cxx14_orig_cxx="$CXX" > + ax_cv_cxx_compile_cxx14_orig_cxxflags="$CXXFLAGS" > + ax_cv_cxx_compile_cxx14_orig_cppflags="$CPPFLAGS" > CXX="$CXX_FOR_BUILD" > CXXFLAGS="$CXXFLAGS_FOR_BUILD" > CPPFLAGS="$CPPFLAGS_FOR_BUILD" > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 > -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } > -if ${ax_cv_cxx_compile_cxx11_FOR_BUILD+:} false; then : > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features by default" >&5 > +$as_echo_n "checking whether $CXX supports C++14 features by default... " >&6; } > +if ${ax_cv_cxx_compile_cxx14_FOR_BUILD+:} false; then : > $as_echo_n "(cached) " >&6 > else > cat confdefs.h - <<_ACEOF >conftest.$ac_ext > @@ -7222,26 +7582,146 @@ namespace cxx11 > > > > + > +// If the compiler admits that it is not ready for C++14, why torture it? > +// Hopefully, this will speed up the test. > + > +#ifndef __cplusplus > + > +#error "This is not a C++ compiler" > + > +#elif __cplusplus < 201402L > + > +#error "This is not a C++14 compiler" > + > +#else > + > +namespace cxx14 > +{ > + > + namespace test_polymorphic_lambdas > + { > + > + int > + test() > + { > + const auto lambda = [](auto&&... args){ > + const auto istiny = [](auto x){ > + return (sizeof(x) == 1UL) ? 1 : 0; > + }; > + const int aretiny[] = { istiny(args)... }; > + return aretiny[0]; > + }; > + return lambda(1, 1L, 1.0f, '1'); > + } > + > + } > + > + namespace test_binary_literals > + { > + > + constexpr auto ivii = 0b0000000000101010; > + static_assert(ivii == 42, "wrong value"); > + > + } > + > + namespace test_generalized_constexpr > + { > + > + template < typename CharT > > + constexpr unsigned long > + strlen_c(const CharT *const s) noexcept > + { > + auto length = 0UL; > + for (auto p = s; *p; ++p) > + ++length; > + return length; > + } > + > + static_assert(strlen_c("") == 0UL, ""); > + static_assert(strlen_c("x") == 1UL, ""); > + static_assert(strlen_c("test") == 4UL, ""); > + static_assert(strlen_c("another\0test") == 7UL, ""); > + > + } > + > + namespace test_lambda_init_capture > + { > + > + int > + test() > + { > + auto x = 0; > + const auto lambda1 = [a = x](int b){ return a + b; }; > + const auto lambda2 = [a = lambda1(x)](){ return a; }; > + return lambda2(); > + } > + > + } > + > + namespace test_digit_separators > + { > + > + constexpr auto ten_million = 100'000'000; > + static_assert(ten_million == 100000000, ""); > + > + } > + > + namespace test_return_type_deduction > + { > + > + auto f(int& x) { return x; } > + decltype(auto) g(int& x) { return x; } > + > + template < typename T1, typename T2 > > + struct is_same > + { > + static constexpr auto value = false; > + }; > + > + template < typename T > > + struct is_same<T, T> > + { > + static constexpr auto value = true; > + }; > + > + int > + test() > + { > + auto x = 0; > + static_assert(is_same<int, decltype(f(x))>::value, ""); > + static_assert(is_same<int&, decltype(g(x))>::value, ""); > + return x; > + } > + > + } > + > +} // namespace cxx14 > + > +#endif // __cplusplus >= 201402L > + > + > + > _ACEOF > if ac_fn_cxx_try_compile "$LINENO"; then : > - ax_cv_cxx_compile_cxx11_FOR_BUILD=yes > + ax_cv_cxx_compile_cxx14_FOR_BUILD=yes > else > - ax_cv_cxx_compile_cxx11_FOR_BUILD=no > + ax_cv_cxx_compile_cxx14_FOR_BUILD=no > fi > rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext > fi > -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11_FOR_BUILD" >&5 > -$as_echo "$ax_cv_cxx_compile_cxx11_FOR_BUILD" >&6; } > - if test x$ax_cv_cxx_compile_cxx11_FOR_BUILD = xyes; then > +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx14_FOR_BUILD" >&5 > +$as_echo "$ax_cv_cxx_compile_cxx14_FOR_BUILD" >&6; } > + if test x$ax_cv_cxx_compile_cxx14_FOR_BUILD = xyes; then > ac_success=yes > fi > > if test x$ac_success = xno; then > for alternative in ${ax_cxx_compile_alternatives}; do > switch="-std=gnu++${alternative}" > - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_FOR_BUILD_$switch" | $as_tr_sh` > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 > -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } > + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_FOR_BUILD_$switch" | $as_tr_sh` > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 > +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } > if eval \${$cachevar+:} false; then : > $as_echo_n "(cached) " >&6 > else > @@ -7537,6 +8017,126 @@ namespace cxx11 > > > > + > +// If the compiler admits that it is not ready for C++14, why torture it? > +// Hopefully, this will speed up the test. > + > +#ifndef __cplusplus > + > +#error "This is not a C++ compiler" > + > +#elif __cplusplus < 201402L > + > +#error "This is not a C++14 compiler" > + > +#else > + > +namespace cxx14 > +{ > + > + namespace test_polymorphic_lambdas > + { > + > + int > + test() > + { > + const auto lambda = [](auto&&... args){ > + const auto istiny = [](auto x){ > + return (sizeof(x) == 1UL) ? 1 : 0; > + }; > + const int aretiny[] = { istiny(args)... }; > + return aretiny[0]; > + }; > + return lambda(1, 1L, 1.0f, '1'); > + } > + > + } > + > + namespace test_binary_literals > + { > + > + constexpr auto ivii = 0b0000000000101010; > + static_assert(ivii == 42, "wrong value"); > + > + } > + > + namespace test_generalized_constexpr > + { > + > + template < typename CharT > > + constexpr unsigned long > + strlen_c(const CharT *const s) noexcept > + { > + auto length = 0UL; > + for (auto p = s; *p; ++p) > + ++length; > + return length; > + } > + > + static_assert(strlen_c("") == 0UL, ""); > + static_assert(strlen_c("x") == 1UL, ""); > + static_assert(strlen_c("test") == 4UL, ""); > + static_assert(strlen_c("another\0test") == 7UL, ""); > + > + } > + > + namespace test_lambda_init_capture > + { > + > + int > + test() > + { > + auto x = 0; > + const auto lambda1 = [a = x](int b){ return a + b; }; > + const auto lambda2 = [a = lambda1(x)](){ return a; }; > + return lambda2(); > + } > + > + } > + > + namespace test_digit_separators > + { > + > + constexpr auto ten_million = 100'000'000; > + static_assert(ten_million == 100000000, ""); > + > + } > + > + namespace test_return_type_deduction > + { > + > + auto f(int& x) { return x; } > + decltype(auto) g(int& x) { return x; } > + > + template < typename T1, typename T2 > > + struct is_same > + { > + static constexpr auto value = false; > + }; > + > + template < typename T > > + struct is_same<T, T> > + { > + static constexpr auto value = true; > + }; > + > + int > + test() > + { > + auto x = 0; > + static_assert(is_same<int, decltype(f(x))>::value, ""); > + static_assert(is_same<int&, decltype(g(x))>::value, ""); > + return x; > + } > + > + } > + > +} // namespace cxx14 > + > +#endif // __cplusplus >= 201402L > + > + > + > _ACEOF > if ac_fn_cxx_try_compile "$LINENO"; then : > eval $cachevar=yes > @@ -7563,9 +8163,9 @@ $as_echo "$ac_res" >&6; } > if test x$ac_success = xno; then > for alternative in ${ax_cxx_compile_alternatives}; do > for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do > - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_FOR_BUILD_$switch" | $as_tr_sh` > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 > -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } > + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_FOR_BUILD_$switch" | $as_tr_sh` > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 > +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } > if eval \${$cachevar+:} false; then : > $as_echo_n "(cached) " >&6 > else > @@ -7861,6 +8461,126 @@ namespace cxx11 > > > > + > +// If the compiler admits that it is not ready for C++14, why torture it? > +// Hopefully, this will speed up the test. > + > +#ifndef __cplusplus > + > +#error "This is not a C++ compiler" > + > +#elif __cplusplus < 201402L > + > +#error "This is not a C++14 compiler" > + > +#else > + > +namespace cxx14 > +{ > + > + namespace test_polymorphic_lambdas > + { > + > + int > + test() > + { > + const auto lambda = [](auto&&... args){ > + const auto istiny = [](auto x){ > + return (sizeof(x) == 1UL) ? 1 : 0; > + }; > + const int aretiny[] = { istiny(args)... }; > + return aretiny[0]; > + }; > + return lambda(1, 1L, 1.0f, '1'); > + } > + > + } > + > + namespace test_binary_literals > + { > + > + constexpr auto ivii = 0b0000000000101010; > + static_assert(ivii == 42, "wrong value"); > + > + } > + > + namespace test_generalized_constexpr > + { > + > + template < typename CharT > > + constexpr unsigned long > + strlen_c(const CharT *const s) noexcept > + { > + auto length = 0UL; > + for (auto p = s; *p; ++p) > + ++length; > + return length; > + } > + > + static_assert(strlen_c("") == 0UL, ""); > + static_assert(strlen_c("x") == 1UL, ""); > + static_assert(strlen_c("test") == 4UL, ""); > + static_assert(strlen_c("another\0test") == 7UL, ""); > + > + } > + > + namespace test_lambda_init_capture > + { > + > + int > + test() > + { > + auto x = 0; > + const auto lambda1 = [a = x](int b){ return a + b; }; > + const auto lambda2 = [a = lambda1(x)](){ return a; }; > + return lambda2(); > + } > + > + } > + > + namespace test_digit_separators > + { > + > + constexpr auto ten_million = 100'000'000; > + static_assert(ten_million == 100000000, ""); > + > + } > + > + namespace test_return_type_deduction > + { > + > + auto f(int& x) { return x; } > + decltype(auto) g(int& x) { return x; } > + > + template < typename T1, typename T2 > > + struct is_same > + { > + static constexpr auto value = false; > + }; > + > + template < typename T > > + struct is_same<T, T> > + { > + static constexpr auto value = true; > + }; > + > + int > + test() > + { > + auto x = 0; > + static_assert(is_same<int, decltype(f(x))>::value, ""); > + static_assert(is_same<int&, decltype(g(x))>::value, ""); > + return x; > + } > + > + } > + > +} // namespace cxx14 > + > +#endif // __cplusplus >= 201402L > + > + > + > _ACEOF > if ac_fn_cxx_try_compile "$LINENO"; then : > eval $cachevar=yes > @@ -7890,28 +8610,28 @@ $as_echo "$ac_res" >&6; } > CXX_FOR_BUILD="$CXX" > CXXFLAGS_FOR_BUILD="$CXXFLAGS" > CPPFLAGS_FOR_BUILD="$CPPFLAGS" > - CXX="$ax_cv_cxx_compile_cxx11_orig_cxx" > - CXXFLAGS="$ax_cv_cxx_compile_cxx11_orig_cxxflags" > - CPPFLAGS="$ax_cv_cxx_compile_cxx11_orig_cppflags" > + CXX="$ax_cv_cxx_compile_cxx14_orig_cxx" > + CXXFLAGS="$ax_cv_cxx_compile_cxx14_orig_cxxflags" > + CPPFLAGS="$ax_cv_cxx_compile_cxx14_orig_cppflags" > ac_ext=c > ac_cpp='$CPP $CPPFLAGS' > ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' > ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' > ac_compiler_gnu=$ac_cv_c_compiler_gnu > > - if test x$ax_cxx_compile_cxx11_required = xtrue; then > + if test x$ax_cxx_compile_cxx14_required = xtrue; then > if test x$ac_success = xno; then > - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 > + as_fn_error $? "*** A compiler with support for C++14 language features is required." "$LINENO" 5 > fi > fi > if test x$ac_success = xno; then > - HAVE_CXX11_FOR_BUILD=0 > - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 > -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} > + HAVE_CXX14_FOR_BUILD=0 > + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++14 support was found" >&5 > +$as_echo "$as_me: No compiler with C++14 support was found" >&6;} > else > - HAVE_CXX11_FOR_BUILD=1 > + HAVE_CXX14_FOR_BUILD=1 > > -$as_echo "#define HAVE_CXX11_FOR_BUILD 1" >>confdefs.h > +$as_echo "#define HAVE_CXX14_FOR_BUILD 1" >>confdefs.h > > fi > > > base-commit: 5c8f9f4d4cebabf85e68c5bdbe2d4ee6646edc7c > -- > 2.46.0 >
On 9/19/24 7:57 AM, Richard Biener wrote: > On Wed, Sep 18, 2024 at 6:22 PM Jason Merrill <jason@redhat.com> wrote: >> >> Tested x86_64-pc-linux-gnu with 5.5.0 bootstrap compiler. Thoughts? > > I'm fine with this in general - do we have needs of bumping the requirement for > GCC 15 though? IMO we should bump once we are requiring actual C++14 > in some place. Jakub's dwarf2asm patch yesterday uses C++14 if available, and I remember seeing a couple of other patches that would have been simpler with C++14 available. > As of the version requirement as you say only some minor versions of the GCC 5 > series are OK I would suggest to say we recommend using GCC 6 or later > but GCC 5.5 should also work? Aren't we already specifying a minor revision with 4.8.3 for C++11? Another possibility would be to just say GCC 5, and adjust that upward if we run into problems. Jason
On Thu, 2024-09-19 at 10:21 -0400, Jason Merrill wrote: /* snip */ > Another possibility would be to just say GCC 5, and adjust that upward > if we run into problems. I'd remind that GCC 5.1 is known as incapable to bootstrap recent GCC releases due to PR 65801.
On Thu, Sep 19, 2024 at 10:21:15AM -0400, Jason Merrill wrote: > On 9/19/24 7:57 AM, Richard Biener wrote: > > On Wed, Sep 18, 2024 at 6:22 PM Jason Merrill <jason@redhat.com> wrote: > > > > > > Tested x86_64-pc-linux-gnu with 5.5.0 bootstrap compiler. Thoughts? > > > > I'm fine with this in general - do we have needs of bumping the requirement for > > GCC 15 though? IMO we should bump once we are requiring actual C++14 > > in some place. > > Jakub's dwarf2asm patch yesterday uses C++14 if available, and I remember And libcpp too. > seeing a couple of other patches that would have been simpler with C++14 > available. It was just a few lines and if I removed the now never true HAVE_DESIGNATED_INITIALIZERS cases, it wouldn't even add any new lines, just change some to others. Both of those patches were just minor optimizations, it is fine if they don't happen during stage1. We also have some spots with #if __cpp_inline_variables < 201606L #else #endif conditionals but that doesn't mean we need to bump to C++17. Sure, bumping the required C++ version means we can remove the corresponding conditionals, and more importantly stop worrying about working around GCC 4.8.x/4.9 bugs (I think that is actually more important). The price is stopping to use some of the cfarm machines for testing or using IBM Advanced Toolchain or hand-built GCC 14 there as the system compiler there. At some point we certainly want to do that, the question is if the benefits right now overweight the pain. > > As of the version requirement as you say only some minor versions of the GCC 5 > > series are OK I would suggest to say we recommend using GCC 6 or later > > but GCC 5.5 should also work? > > Aren't we already specifying a minor revision with 4.8.3 for C++11? > > Another possibility would be to just say GCC 5, and adjust that upward if we > run into problems. I think for the oldest supported version we need some CFarm machines around with that compiler so that all people can actually test issues with it. Dunno which distros shipped GCC 5 in long term support versions if any and at which minor those are. Jakub
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index e339d736969..87add0b6572 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -222,17 +222,18 @@ described below. @heading Tools/packages necessary for building GCC @table @asis -@item ISO C++11 compiler -Necessary to bootstrap GCC. GCC 4.8.3 or newer has sufficient -support for used C++11 features. +@item ISO C++14 compiler +Necessary to bootstrap GCC. GCC 5.5 or newer has sufficient +support for used C++14 features. -Versions of GCC prior to 11 also allow bootstrapping with an ISO C++98 -compiler, and versions of GCC prior to 4.8 also allow bootstrapping with -an ISO C89 compiler. +Versions of GCC prior to 15 allow bootstrapping with an ISO C++11 +compiler, versions prior to 11 allow bootstrapping with an ISO C++98 +compiler, and versions prior to 4.8 allow bootstrapping with an ISO +C89 compiler. To build all languages in a cross-compiler or other configuration where 3-stage bootstrap is not performed, you need to start with an existing -GCC binary (version 4.8.3 or later) because source code for language +GCC binary (version 5.5 or later) because source code for language frontends other than C might use GCC extensions. @item C standard library and headers diff --git a/configure.ac b/configure.ac index f61dbe64a94..91635d5368a 100644 --- a/configure.ac +++ b/configure.ac @@ -1457,16 +1457,16 @@ case "$have_compiler:$host:$target:$enable_bootstrap" in ;; esac -# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a -# C++11 compiler can still start the bootstrap. Otherwise, if building GCC, -# require C++11 (or higher). +# When bootstrapping with GCC, build stage 1 in C++14 mode to ensure that a +# C++14 compiler can still start the bootstrap. Otherwise, if building GCC, +# require C++14 (or higher). if test "$enable_bootstrap:$GXX" = "yes:yes"; then - CXX="$CXX -std=c++11" + CXX="$CXX -std=c++14" elif test "$have_compiler" = yes; then - AX_CXX_COMPILE_STDCXX(11) + AX_CXX_COMPILE_STDCXX(14) if test "${build}" != "${host}"; then - AX_CXX_COMPILE_STDCXX(11, [], [], [_FOR_BUILD]) + AX_CXX_COMPILE_STDCXX(14, [], [], [_FOR_BUILD]) fi fi diff --git a/configure b/configure index e9583f2ba0c..ab9719c6e93 100755 --- a/configure +++ b/configure @@ -712,8 +712,8 @@ gmplibs PGO_BUILD_LTO_CFLAGS PGO_BUILD_USE_CFLAGS PGO_BUILD_GEN_CFLAGS -HAVE_CXX11_FOR_BUILD -HAVE_CXX11 +HAVE_CXX14_FOR_BUILD +HAVE_CXX14 do_compare CARGO GDC @@ -5914,13 +5914,13 @@ $as_echo "$as_me: WARNING: trying to bootstrap a cross compiler" >&2;} ;; esac -# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a -# C++11 compiler can still start the bootstrap. Otherwise, if building GCC, -# require C++11 (or higher). +# When bootstrapping with GCC, build stage 1 in C++14 mode to ensure that a +# C++14 compiler can still start the bootstrap. Otherwise, if building GCC, +# require C++14 (or higher). if test "$enable_bootstrap:$GXX" = "yes:yes"; then - CXX="$CXX -std=c++11" + CXX="$CXX -std=c++14" elif test "$have_compiler" = yes; then - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true + ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=true ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -5928,9 +5928,9 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_success=no - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } -if ${ax_cv_cxx_compile_cxx11+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features by default" >&5 +$as_echo_n "checking whether $CXX supports C++14 features by default... " >&6; } +if ${ax_cv_cxx_compile_cxx14+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -6223,26 +6223,146 @@ namespace cxx11 + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same<int, decltype(f(x))>::value, ""); + static_assert(is_same<int&, decltype(g(x))>::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + + _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : - ax_cv_cxx_compile_cxx11=yes + ax_cv_cxx_compile_cxx14=yes else - ax_cv_cxx_compile_cxx11=no + ax_cv_cxx_compile_cxx14=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 -$as_echo "$ax_cv_cxx_compile_cxx11" >&6; } - if test x$ax_cv_cxx_compile_cxx11 = xyes; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx14" >&5 +$as_echo "$ax_cv_cxx_compile_cxx14" >&6; } + if test x$ax_cv_cxx_compile_cxx14 = xyes; then ac_success=yes fi if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do switch="-std=gnu++${alternative}" - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : $as_echo_n "(cached) " >&6 else @@ -6538,6 +6658,126 @@ namespace cxx11 + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same<int, decltype(f(x))>::value, ""); + static_assert(is_same<int&, decltype(g(x))>::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + + _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval $cachevar=yes @@ -6564,9 +6804,9 @@ $as_echo "$ac_res" >&6; } if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : $as_echo_n "(cached) " >&6 else @@ -6862,6 +7102,126 @@ namespace cxx11 + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same<int, decltype(f(x))>::value, ""); + static_assert(is_same<int&, decltype(g(x))>::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + + _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval $cachevar=yes @@ -6895,41 +7255,41 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu - if test x$ax_cxx_compile_cxx11_required = xtrue; then + if test x$ax_cxx_compile_cxx14_required = xtrue; then if test x$ac_success = xno; then - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 + as_fn_error $? "*** A compiler with support for C++14 language features is required." "$LINENO" 5 fi fi if test x$ac_success = xno; then - HAVE_CXX11=0 - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} + HAVE_CXX14=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++14 support was found" >&5 +$as_echo "$as_me: No compiler with C++14 support was found" >&6;} else - HAVE_CXX11=1 + HAVE_CXX14=1 -$as_echo "#define HAVE_CXX11 1" >>confdefs.h +$as_echo "#define HAVE_CXX14 1" >>confdefs.h fi if test "${build}" != "${host}"; then - ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=true + ax_cxx_compile_alternatives="14 1y" ax_cxx_compile_cxx14_required=true ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_success=no - ax_cv_cxx_compile_cxx11_orig_cxx="$CXX" - ax_cv_cxx_compile_cxx11_orig_cxxflags="$CXXFLAGS" - ax_cv_cxx_compile_cxx11_orig_cppflags="$CPPFLAGS" + ax_cv_cxx_compile_cxx14_orig_cxx="$CXX" + ax_cv_cxx_compile_cxx14_orig_cxxflags="$CXXFLAGS" + ax_cv_cxx_compile_cxx14_orig_cppflags="$CPPFLAGS" CXX="$CXX_FOR_BUILD" CXXFLAGS="$CXXFLAGS_FOR_BUILD" CPPFLAGS="$CPPFLAGS_FOR_BUILD" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 -$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } -if ${ax_cv_cxx_compile_cxx11_FOR_BUILD+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features by default" >&5 +$as_echo_n "checking whether $CXX supports C++14 features by default... " >&6; } +if ${ax_cv_cxx_compile_cxx14_FOR_BUILD+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7222,26 +7582,146 @@ namespace cxx11 + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same<int, decltype(f(x))>::value, ""); + static_assert(is_same<int&, decltype(g(x))>::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + + _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : - ax_cv_cxx_compile_cxx11_FOR_BUILD=yes + ax_cv_cxx_compile_cxx14_FOR_BUILD=yes else - ax_cv_cxx_compile_cxx11_FOR_BUILD=no + ax_cv_cxx_compile_cxx14_FOR_BUILD=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11_FOR_BUILD" >&5 -$as_echo "$ax_cv_cxx_compile_cxx11_FOR_BUILD" >&6; } - if test x$ax_cv_cxx_compile_cxx11_FOR_BUILD = xyes; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx14_FOR_BUILD" >&5 +$as_echo "$ax_cv_cxx_compile_cxx14_FOR_BUILD" >&6; } + if test x$ax_cv_cxx_compile_cxx14_FOR_BUILD = xyes; then ac_success=yes fi if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do switch="-std=gnu++${alternative}" - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_FOR_BUILD_$switch" | $as_tr_sh` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_FOR_BUILD_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : $as_echo_n "(cached) " >&6 else @@ -7537,6 +8017,126 @@ namespace cxx11 + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same<int, decltype(f(x))>::value, ""); + static_assert(is_same<int&, decltype(g(x))>::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + + _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval $cachevar=yes @@ -7563,9 +8163,9 @@ $as_echo "$ac_res" >&6; } if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do - cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_FOR_BUILD_$switch" | $as_tr_sh` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 -$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } + cachevar=`$as_echo "ax_cv_cxx_compile_cxx14_FOR_BUILD_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++14 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++14 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : $as_echo_n "(cached) " >&6 else @@ -7861,6 +8461,126 @@ namespace cxx11 + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same<T, T> + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same<int, decltype(f(x))>::value, ""); + static_assert(is_same<int&, decltype(g(x))>::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + + + _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval $cachevar=yes @@ -7890,28 +8610,28 @@ $as_echo "$ac_res" >&6; } CXX_FOR_BUILD="$CXX" CXXFLAGS_FOR_BUILD="$CXXFLAGS" CPPFLAGS_FOR_BUILD="$CPPFLAGS" - CXX="$ax_cv_cxx_compile_cxx11_orig_cxx" - CXXFLAGS="$ax_cv_cxx_compile_cxx11_orig_cxxflags" - CPPFLAGS="$ax_cv_cxx_compile_cxx11_orig_cppflags" + CXX="$ax_cv_cxx_compile_cxx14_orig_cxx" + CXXFLAGS="$ax_cv_cxx_compile_cxx14_orig_cxxflags" + CPPFLAGS="$ax_cv_cxx_compile_cxx14_orig_cppflags" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu - if test x$ax_cxx_compile_cxx11_required = xtrue; then + if test x$ax_cxx_compile_cxx14_required = xtrue; then if test x$ac_success = xno; then - as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 + as_fn_error $? "*** A compiler with support for C++14 language features is required." "$LINENO" 5 fi fi if test x$ac_success = xno; then - HAVE_CXX11_FOR_BUILD=0 - { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 -$as_echo "$as_me: No compiler with C++11 support was found" >&6;} + HAVE_CXX14_FOR_BUILD=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++14 support was found" >&5 +$as_echo "$as_me: No compiler with C++14 support was found" >&6;} else - HAVE_CXX11_FOR_BUILD=1 + HAVE_CXX14_FOR_BUILD=1 -$as_echo "#define HAVE_CXX11_FOR_BUILD 1" >>confdefs.h +$as_echo "#define HAVE_CXX14_FOR_BUILD 1" >>confdefs.h fi