[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)
commit9b4d030ed52b52fe208edaa8be640f4dd359defc
treebd8fe83aea01665015f6d217726a5220bdad9186
parent7061d67445c4ee9dd41ce4d3f7cccb71cd54d853
[gdb/build] Add CXX_DIALECT to CXX

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
This page took 0.02643 seconds and 4 git commands to generate.