[master+11,gdb/build] Add CXX_DIALECT to CXX

Message ID 20210908121519.GA17723@delia
State New
Headers show
Series
  • [master+11,gdb/build] Add CXX_DIALECT to CXX
Related show

Commit Message

Tom de Vries via Gdb-patches Sept. 8, 2021, 12:15 p.m.
Hi,

The problem reported in PR28318 is that when using a gcc version that (while
supporting c++11) does not support c++11 by default, the configure test for
std::thread support will fail.

If gdb would use the default AX_CXX_COMPILE_STDCXX from autoconf, then we'd
have:
...
CXX="g++ -std=gnu++11"
...
and the test for std::thread support would succeed.

Instead, gdb uses a custom AX_CXX_COMPILE_STDCXX (see commit 0bcda685399)
which does:
...
CXX=g++
CXX_DIALECT=-std=gnu++11
...

We could add $CXX_DIALECT to the test for std::thread support, but that would
have to be repeated for each added c++ support test.

Instead, fix this by doing:
...
CXX="g++ -std=gnu++11"
CXX_DIALECT=-std=gnu++11
...

The code added in gdb/ax_cxx_compile_stdcxx.m4 is copied from the default
AX_CXX_COMPILE_STDCXX from autoconf.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28318

Any comments?

Thanks,
- Tom

[gdb/build] Add CXX_DIALECT to CXX

---
 gdb/ax_cxx_compile_stdcxx.m4 | 8 ++++++++
 gdb/configure                | 8 ++++++++
 gdbserver/configure          | 8 ++++++++
 gdbsupport/configure         | 8 ++++++++
 4 files changed, 32 insertions(+)

Patch

diff --git a/gdb/ax_cxx_compile_stdcxx.m4 b/gdb/ax_cxx_compile_stdcxx.m4
index 413755a2e88..29d8e10bcc4 100644
--- a/gdb/ax_cxx_compile_stdcxx.m4
+++ b/gdb/ax_cxx_compile_stdcxx.m4
@@ -94,6 +94,10 @@  AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
          CXX="$ac_save_CXX"])
       if eval test x\$$cachevar = xyes; then
         CXX_DIALECT="$switch"
+        CXX="$CXX $switch"
+        if test -n "$CXXCPP" ; then
+          CXXCPP="$CXXCPP $switch"
+        fi
         ac_success=yes
         break
       fi
@@ -118,6 +122,10 @@  AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
            CXX="$ac_save_CXX"])
         if eval test x\$$cachevar = xyes; then
           CXX_DIALECT="$switch"
+          CXX="$CXX $switch"
+          if test -n "$CXXCPP" ; then
+            CXXCPP="$CXXCPP $switch"
+          fi
           ac_success=yes
           break
         fi
diff --git a/gdb/configure b/gdb/configure
index f0b1af4a6ea..98badb46cfd 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -5841,6 +5841,10 @@  eval ac_res=\$$cachevar
 $as_echo "$ac_res" >&6; }
       if eval test x\$$cachevar = xyes; then
         CXX_DIALECT="$switch"
+        CXX="$CXX $switch"
+        if test -n "$CXXCPP" ; then
+          CXXCPP="$CXXCPP $switch"
+        fi
         ac_success=yes
         break
       fi
@@ -6160,6 +6164,10 @@  eval ac_res=\$$cachevar
 $as_echo "$ac_res" >&6; }
         if eval test x\$$cachevar = xyes; then
           CXX_DIALECT="$switch"
+          CXX="$CXX $switch"
+          if test -n "$CXXCPP" ; then
+            CXXCPP="$CXXCPP $switch"
+          fi
           ac_success=yes
           break
         fi
diff --git a/gdbserver/configure b/gdbserver/configure
index b227167e270..f05c1a9b976 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -5625,6 +5625,10 @@  eval ac_res=\$$cachevar
 $as_echo "$ac_res" >&6; }
       if eval test x\$$cachevar = xyes; then
         CXX_DIALECT="$switch"
+        CXX="$CXX $switch"
+        if test -n "$CXXCPP" ; then
+          CXXCPP="$CXXCPP $switch"
+        fi
         ac_success=yes
         break
       fi
@@ -5944,6 +5948,10 @@  eval ac_res=\$$cachevar
 $as_echo "$ac_res" >&6; }
         if eval test x\$$cachevar = xyes; then
           CXX_DIALECT="$switch"
+          CXX="$CXX $switch"
+          if test -n "$CXXCPP" ; then
+            CXXCPP="$CXXCPP $switch"
+          fi
           ac_success=yes
           break
         fi
diff --git a/gdbsupport/configure b/gdbsupport/configure
index a9dd02c5b72..ae6047865ae 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -6520,6 +6520,10 @@  eval ac_res=\$$cachevar
 $as_echo "$ac_res" >&6; }
       if eval test x\$$cachevar = xyes; then
         CXX_DIALECT="$switch"
+        CXX="$CXX $switch"
+        if test -n "$CXXCPP" ; then
+          CXXCPP="$CXXCPP $switch"
+        fi
         ac_success=yes
         break
       fi
@@ -6839,6 +6843,10 @@  eval ac_res=\$$cachevar
 $as_echo "$ac_res" >&6; }
         if eval test x\$$cachevar = xyes; then
           CXX_DIALECT="$switch"
+          CXX="$CXX $switch"
+          if test -n "$CXXCPP" ; then
+            CXXCPP="$CXXCPP $switch"
+          fi
           ac_success=yes
           break
         fi