public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/build] Add CXX_DIALECT to CXX
@ 2021-10-04 16:51 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2021-10-04 16:51 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=77252bf26e98bda49baffc2657bd99143e1c7626
commit 77252bf26e98bda49baffc2657bd99143e1c7626
Author: Tom de Vries <tdevries@suse.de>
Date: Mon Oct 4 18:51:09 2021 +0200
[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
Diff:
---
gdb/ax_cxx_compile_stdcxx.m4 | 8 ++++++++
gdb/configure | 8 ++++++++
gdbserver/configure | 8 ++++++++
gdbsupport/configure | 8 ++++++++
4 files changed, 32 insertions(+)
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 7c8335f2576..1876cbfefa4 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -5846,6 +5846,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
@@ -6165,6 +6169,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 08800228aa5..f13ae76641f 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-04 16:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04 16:51 [binutils-gdb] [gdb/build] Add CXX_DIALECT to CXX Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).