[gdb/build] Add CXX_DIALECT to CXX
authorTom de Vries <tdevries@suse.de>
Mon, 4 Oct 2021 16:56:42 +0000 (18:56 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 4 Oct 2021 16:56:42 +0000 (18:56 +0200)
Say we use a gcc version that (while supporting c++11) does not support c++11
by default, and needs an -std setting to enable it.

If gdb would use the default AX_CXX_COMPILE_STDCXX from autoconf-archive, then
we'd have:
...
CXX="g++ -std=gnu++11"
...

That mechanism however has the following problem (quoting from commit
0bcda685399):
...
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.
...

Commit 0bcda685399 fixes this by using a custom AX_CXX_COMPILE_STDCXX which
does:
...
CXX=g++
CXX_DIALECT=-std=gnu++11
...

The problem reported in PR28318 is that using the custom instead of the
default AX_CXX_COMPILE_STDCXX makes the configure test for std::thread
support fail.

We could simply 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
...

This is somewhat awkward, since it results in -std=gnu++11 occuring twice in
some situations:
...
$ touch src/gdb/dwarf2/read.c
$ ( cd build/gdb; make V=1 dwarf2/read.o )
g++-4.8 -std=gnu++11 -x c++ -std=gnu++11 ...
...

However, both settings are needed:
 - the switch in CXX for the std::thread tests (and other tests)
 - the switch in CXX_DIALECT so it can be appended in Makefiles, to
   counteract the fact that the top-level Makefile overrides CXX

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

Tested on x86_64-linux.

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

gdb/ChangeLog:

2021-10-04  Tom de Vries  <tdevries@suse.de>

PR build/28318
* ax_cxx_compile_stdcxx.m4: Add CXX_DIALECT to CXX.
* configure: Regenerate.

gdbserver/ChangeLog:

2021-10-04  Tom de Vries  <tdevries@suse.de>

PR build/28318
* configure: Regenerate.

gdbsupport/ChangeLog:

2021-10-04  Tom de Vries  <tdevries@suse.de>

PR build/28318
* configure: Regenerate.

gdb/ChangeLog
gdb/ax_cxx_compile_stdcxx.m4
gdb/configure
gdbserver/ChangeLog
gdbserver/configure
gdbsupport/ChangeLog
gdbsupport/configure

index 0974273183eb3870af2585c63720dfa58ef1593c..21c305cddf597e88ad110f5abf23e50ab8f0f8b5 100644 (file)
@@ -1,3 +1,9 @@
+2021-10-04  Tom de Vries  <tdevries@suse.de>
+
+       PR build/28318
+       * ax_cxx_compile_stdcxx.m4: Add CXX_DIALECT to CXX.
+       * configure: Regenerate.
+
 2021-09-13  Joel Brobecker  <brobecker@adacore.com>
 
        * version.in: Set GDB version number to 11.1.90.DATE-git.
index 413755a2e886c69ae8eff75cadb9db5390cf0cb6..29d8e10bcc4017624d468d4820589cee0fbfacb3 100644 (file)
@@ -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
index 5d89635c043fb745aa562136c1e919c0874579bc..6d4c2b17ed2ef4f411e1d838b1236b7710dfcd27 100755 (executable)
@@ -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
index f6a49f37e70797ce5db03a781c021e9fd6dc6bf0..8061f7e83d786ff3b3672eaec87891cb66e6d749 100644 (file)
@@ -1,3 +1,8 @@
+2021-10-04  Tom de Vries  <tdevries@suse.de>
+
+       PR build/28318
+       * configure: Regenerate.
+
 2021-07-05  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * config.in, configure: Re-generate.
index b227167e270c0ca2cbed6e0f333d39b7e5b05705..f05c1a9b9761e47144b37150ef38eebcbebdf642 100755 (executable)
@@ -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
index 7f17e7a57e52cb1dec04eb40a619ea242ee37db2..d4a545b4a1899fada59036c462b1e21181640431 100644 (file)
@@ -1,3 +1,8 @@
+2021-10-04  Tom de Vries  <tdevries@suse.de>
+
+       PR build/28318
+       * configure: Regenerate.
+
 2021-07-30  Tom de Vries  <tdevries@suse.de>
 
        * common-defs.h (ATTRIBUTE_NONNULL): Disable.
index a9dd02c5b7224854ae3cffcc5be527f68b2fc832..ae6047865ae7645fb90ca0ba1a6d432240d85ded 100755 (executable)
@@ -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
This page took 0.0460390000000001 seconds and 4 git commands to generate.