Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] gdb: Require a C++11 compiler
@ 2016-10-27 19:21 Pedro Alves
  2016-10-27 19:21 ` [PATCH 2/2] gdb: Require C++11 Pedro Alves
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Pedro Alves @ 2016-10-27 19:21 UTC (permalink / raw)
  To: gdb-patches

As previously discussed, this patch set makes GDB require a C++11
compiler.

You'll find the previous discussions referenced here:
  https://sourceware.org/ml/gdb-patches/2016-10/msg00607.html

This is basically the same as I had sent here:
  https://sourceware.org/ml/gdb-patches/2016-10/msg00336.html

The only difference is a single-line change that makes C++11 a
mandatory instead of enabling it iff supported.

Pedro Alves (2):
  gdb: Import AX_CXX_COMPILE_STDCXX from the GNU Autoconf Archive
  gdb: Require C++11

 gdb/Makefile.in              |   6 +-
 gdb/acinclude.m4             |   2 +
 gdb/ax_cxx_compile_stdcxx.m4 | 567 +++++++++++++++++++++++++
 gdb/config.in                |   3 +
 gdb/configure                | 981 ++++++++++++++++++++++++++++++++++++++++++-
 gdb/configure.ac             |   4 +
 gdb/gdbserver/Makefile.in    |   5 +-
 gdb/gdbserver/acinclude.m4   |   2 +
 gdb/gdbserver/config.in      |   3 +
 gdb/gdbserver/configure      | 981 ++++++++++++++++++++++++++++++++++++++++++-
 gdb/gdbserver/configure.ac   |   4 +
 11 files changed, 2552 insertions(+), 6 deletions(-)
 create mode 100644 gdb/ax_cxx_compile_stdcxx.m4

-- 
2.5.5


^ permalink raw reply	[flat|nested] 22+ messages in thread
* [PATCH] Enable C++11 starting with gcc 4.8 (was: Re: [PATCH 1/3] Introduce gdb::unique_ptr)
@ 2016-10-13  0:38 Pedro Alves
  2016-10-13  0:45 ` [PATCH 1/2] gdb: Import AX_CXX_COMPILE_STDCXX from the GNU Autoconf Archive Pedro Alves
  0 siblings, 1 reply; 22+ messages in thread
From: Pedro Alves @ 2016-10-13  0:38 UTC (permalink / raw)
  To: Metzger, Markus T, Eli Zaretskii
  Cc: brobecker, gdb-patches,
	Jan Kratochvil (jan.kratochvil@redhat.com),
	Simon Marchi

On 10/12/2016 11:28 AM, Pedro Alves wrote:
> On 10/12/2016 09:11 AM, Metzger, Markus T wrote:
> 
>> A simple and pragmatic solution would be a patch to add -std=c++11
>> to GDB's compiler options.  Pedro already mentioned it but I'm afraid it
>> got lost.
> 
> Looks like it, yes.  As I've explained, we can't do it on src/gdb/
> alone, because the CXX make variable is passed down from the top level,
> which would override whatever we set in gdb/'s configure/Makefile.
> 
> I want to give it a try, though.  It just requires time and getting
> the patch into gcc and merged back.  I don't think that should hold
> back the proposed series (or pieces of it).
> 
> I wasn't originally meaning to unconditionally add -std=c++11 though,
> but instead to only add it if the compiler supports it, in order
> to conservatively still support C++03-only compilers.

OK, I spend a few hours tonight working on this.

I was thinking ahead that we'll like have other C++ libraries in
the top level that we'd be using (code shared with gcc, and also
gdbserver moving to top level, maybe parts split to libraries, etc.).

And I was mistakenly under the impression that all subdirs would have to be
built with the same C++ dialect, given the C++11 ABI change.  I.e.,
use the same dialect throughout to avoid ABI conflicts.

So I first wrote a patch that had the top level configure source a
file in each subdir that would tell the top level the minimum and
maximum C++ dialect versions each subdir supported, and then the
top level could compute the dialect to set CXX to.

But,
 https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
explains how mixing dialects is not really a problem.

So I was over complicating.

However, the issue with CXX being passed by the top level overriding
whatever gdb's configure/Makefile decide to set CXX to is
real though.  But I solved it in a different way, all within gdb/

Instead of having configure append -std=xxx to CXX, simply set a
separate CXX_DIALECT variable, and tweak the Makefile to use
"$CXX CXX_DIALECT" to compile/link.

In order to detect whether the compiler supports C++11 (i.e.,
if we're using gcc 4.8 or later, or a clang that supports C++11,
etc.), I'm reusing a macro from the GNU Autoconf Archive, at:

 http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html

To recap:

> Conceptually, the gdb::unique_ptr patch (this thread) does:
> 
> #if HAVE_STD_UNIQUE_PTR
> 
> // just use it
> 
> #else
> 
> // write replacement
> 
> #endif
> 
> The replacement is fully functional.
> 
> If I push the patch in now, HAVE_STD_UNIQUE_PTR will only be true
> when compiling GDB with GCC >= 6.x, because G++ 6.1 targets G++14
> by default, which is a superset of C++11.  The replacement
> works with all other GCCs.  It'd be possible to make
> HAVE_STD_UNIQUE_PTR be true with GCC >= 4.x too, but nobody wrote
> that patch yet.

So I wrote that patch now.

IOW, the idea is that gdb::unique_ptr maps to C++11
std::unique_ptr iff C++11 is available and to a replacement
otherwise.  The C++03 replacement works just as well, however
the C++11 version catches more bugs at compile time.

Full C++11 support is available starting with gcc 4.8, however
only gcc 6.1 switched to default to C++11 (C++14, actually).
So for gcc 4.8 till gcc 6.1, we need to explicitly pass -std=gnu++11
to the compiler.  That's what the patch I wrote tonight does.
I'll send it as reply to this email.  Two patches actually.

> But if we agree to go full-on C++11, then I'll be more than
> happy to make gdb's configure error out on non-C++11 compilers.

The patches add this to configure:

 AX_CXX_COMPILE_STDCXX(11, , optional)

"optional" means that not having a C++11 compiler is OK.
IOW, "try to enable C++11 iff possible".

If we decide to _require_ C++11 (i.e., drop support for C++03-only), then
it's a simple matter of changing that to:

 AX_CXX_COMPILE_STDCXX(11, , mandatory)

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2016-11-04 14:46 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 19:21 [PATCH 0/2] gdb: Require a C++11 compiler Pedro Alves
2016-10-27 19:21 ` [PATCH 2/2] gdb: Require C++11 Pedro Alves
     [not found]   ` <20161028104718.540c10ed@ThinkPad>
2016-10-28  9:03     ` Pedro Alves
2016-10-28 10:44       ` Philipp Rudo
2016-11-03 15:39   ` Yao Qi
2016-11-03 15:58     ` Pedro Alves
2016-11-03 16:11       ` Yao Qi
2016-10-27 19:21 ` [PATCH 1/2] gdb: Import AX_CXX_COMPILE_STDCXX from the GNU Autoconf Archive Pedro Alves
2016-10-28 12:07 ` [PATCH 0/2] gdb: Require a C++11 compiler Yao Qi
2016-10-28 15:08   ` Pedro Alves
2016-10-28 17:17     ` [PATCH] gdb/NEWS: Mention C++11 requirement Pedro Alves
2016-10-29  6:13       ` Eli Zaretskii
2016-10-29 15:18         ` Pedro Alves
2016-10-29 15:29           ` Eli Zaretskii
2016-10-29 15:35             ` Pedro Alves
2016-11-01 11:00 ` [PATCH 0/2] gdb: Require a C++11 compiler Richard Earnshaw (lists)
2016-11-01 16:53   ` Pedro Alves
2016-11-02 14:51     ` Richard Earnshaw (lists)
2016-11-02 15:58       ` Pedro Alves
2016-11-04 13:31     ` Maciej W. Rozycki
2016-11-04 14:46       ` Pedro Alves
  -- strict thread matches above, loose matches on Subject: below --
2016-10-13  0:38 [PATCH] Enable C++11 starting with gcc 4.8 (was: Re: [PATCH 1/3] Introduce gdb::unique_ptr) Pedro Alves
2016-10-13  0:45 ` [PATCH 1/2] gdb: Import AX_CXX_COMPILE_STDCXX from the GNU Autoconf Archive Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox