diff options
author | 2016-10-13 00:27:45 +0100 | |
---|---|---|
committer | 2016-10-28 16:03:19 +0100 | |
commit | 0bcda68539948828795564b35a497dc69c27f768 (patch) | |
tree | ffba724695a70ecf58bd556ee6f39cf52af099f2 /gdb/ax_cxx_compile_stdcxx.m4 | |
parent | gdb: Import AX_CXX_COMPILE_STDCXX from the GNU Autoconf Archive (diff) | |
download | binutils-gdb-0bcda68539948828795564b35a497dc69c27f768.tar.gz binutils-gdb-0bcda68539948828795564b35a497dc69c27f768.tar.bz2 binutils-gdb-0bcda68539948828795564b35a497dc69c27f768.zip |
gdb: Require C++11
Use AX_CXX_COMPILE_STDCXX to detect if the compiler supports C++11,
and if -std=xxx switches are necessary to enable C++11.
We need to tweak AX_CXX_COMPILE_STDCXX a bit though. Pristine
upstream AX_CXX_COMPILE_STDCXX appends -std=gnu++11 to CXX directly.
That doesn't work for us, because the top level Makefile passes CXX
down to subdirs, and that overrides whatever gdb/Makefile may set CXX
to. The result would be that a make invocation from the build/gdb/
directory would use "g++ -std=gnu++11" as expected, while a make
invocation at the top level would not.
So instead of having AX_CXX_COMPILE_STDCXX set CXX directly, tweak it
to AC_SUBST a separate variable -- CXX_DIALECT -- and use '$(CXX)
(CXX_DIALECT)' to compile/link.
Confirmed that this enables C++11 starting with gcc 4.8, the first gcc
release with full C++11 support.
Also confirmed that configure errors out gracefully with older GCC
releases:
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features by default... no
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -std=gnu++11... no
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -std=gnu++0x... no
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -std=c++11... no
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -std=c++0x... no
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with +std=c++11... no
checking whether /opt/gcc-4.7/bin/g++ supports C++11 features with -h std=c++11... no
configure: error: *** A compiler with support for C++11 language features is required.
Makefile:9451: recipe for target 'configure-gdb' failed
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory '/home/pedro/brno/pedro/gdb/mygit/cxx-convertion/build-gcc-4.7'
If we need to revert back to making C++11 optional, all that's
necessary is to change the "mandatory" to "optional" in configure.ac
and regenerate configure (both gdb and gdbserver).
gdb/ChangeLog:
2016-10-28 Pedro Alves <palves@redhat.com>
* Makefile.in (CXX_DIALECT): Get from configure.
(COMPILE.pre, CC_LD): Append $(CXX_DIALECT).
(FLAGS_TO_PASS): Pass CXX_DIALECT.
* acinclude.m4: Include ax_cxx_compile_stdcxx.m4.
* ax_cxx_compile_stdcxx.m4: Add FSF copyright header. Set and
AC_SUBST CXX_DIALECT instead of changing CXX/CXXCPP.
* configure.ac: Call AX_CXX_COMPILE_STDCXX.
* config.in: Regenerate.
* configure: Regenerate.
gdb/gdbserver/ChangeLog:
2016-10-28 Pedro Alves <palves@redhat.com>
* Makefile.in (CXX_DIALECT): Get from configure.
(COMPILE.pre, CC_LD): Append $(CXX_DIALECT).
* acinclude.m4: Include ../ax_cxx_compile_stdcxx.m4.
* configure.ac: Call AX_CXX_COMPILE_STDCXX.
* config.in: Regenerate.
* configure: Regenerate.
Diffstat (limited to 'gdb/ax_cxx_compile_stdcxx.m4')
-rw-r--r-- | gdb/ax_cxx_compile_stdcxx.m4 | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/gdb/ax_cxx_compile_stdcxx.m4 b/gdb/ax_cxx_compile_stdcxx.m4 index 2c18e49c56c..ffaeb6e3bbf 100644 --- a/gdb/ax_cxx_compile_stdcxx.m4 +++ b/gdb/ax_cxx_compile_stdcxx.m4 @@ -1,3 +1,12 @@ +# Copyright (c) 2016 Free Software Foundation, Inc. +# +# Originally based on the AX_CXX_COMPILE_STDCXX macro found at the url +# below. +# +# Local GDB customizations: +# +# - AC_SUBST CXX_DIALECT instead of changing CXX/CXXCPP. +# # =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html # =========================================================================== @@ -58,6 +67,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl [$3], [optional], [ax_cxx_compile_cxx$1_required=false], [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) AC_LANG_PUSH([C++])dnl + CXX_DIALECT="" ac_success=no AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, ax_cv_cxx_compile_cxx$1, @@ -81,10 +91,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl [eval $cachevar=no]) CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" - fi + CXX_DIALECT="$switch" ac_success=yes break fi @@ -107,10 +114,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl [eval $cachevar=no]) CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" - fi + CXX_DIALECT="$switch" ac_success=yes break fi @@ -131,6 +135,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl [define if the compiler supports basic C++$1 syntax]) fi AC_SUBST(HAVE_CXX$1) + AC_SUBST(CXX_DIALECT) ]) |