From: Lancelot SIX <lancelot.six@amd.com>
To: Tom de Vries <tdevries@suse.de>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH RFC] Require c++17 compiler
Date: Thu, 5 Oct 2023 10:33:54 +0000 [thread overview]
Message-ID: <20231005103354.5loeki67slszfrcy@hpe6u-23> (raw)
In-Reply-To: <20231005065449.32643-1-tdevries@suse.de>
[-- Attachment #1: Type: text/plain, Size: 5352 bytes --]
Hi Tom,
Thanks for putting this together! As you know, I am in favor of such
change (for GDB-15 probably, GDB-14 branching is probably too close)!
I do have a really similar patch available on a local branch. One
difference though is that my branch uses a preparatory patch to upgrade
gdb/ax_cxx_compile_stdcxx.m4 to follow upstream changes to this file.
This upgrade gives some improvements in the C++17 compiler detection.
We keep this in the GDB tree because it has some local changes to set
CXX_DIALECT. This preparatory patch should be included in this reply.
On Thu, Oct 05, 2023 at 08:54:49AM +0200, Tom de Vries wrote:
> Since gdb 8.0, we've required a c++11 compiler.
>
> That allowed gdb to be compiled with gcc releases as far back as gcc 4.8,
> using an explicit -std=c++11 to override the default.
>
> [ Gcc has the following defaults:
> - before gcc 6: c++98, and
> - for gcc 6-10: c++14, and
> - since gcc 11: c++17. ]
>
> There are two arguments in favor of moving to requiring a newer c++ standard:
> - benefits can be had from using newer c++ features. We're already using some
> of those features using gdb-specific implementations.
> - when developing gdb on modern platforms with system compiler gcc >= 6,
> people can accidentally use c++14/c++17 features in a patch, only to find out
> post-commit that it breaks the build on a system with a compiler that only
> supports c++11, which is inconvenient and takes time to fix.
> [ This could be partially mitigated by if possible also forcing -std=c++11
> for such compilers. ]
Thanks for pointing this out, this was one trigger for me to start
looking into this!
>
> The need to keep requiring c++11 comes from porting new gdb releases to older
> systems with older system compilers.
>
> A review of some relevant distros has shown that in case that requiring c++17
> results in no longer being able to use the system compiler, an alternative,
> newer compiler that does support c++17 is readily available.
>
> With nothing holding back the change, require a c++17 compiler to build gdb.
Just for the record, it might be worth mentioning here the general
policy of the project regarding bumping the C++ required version:
https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#When_is_GDB_going_to_start_requiring_C.2B-.2B-NN_.3F
>
> The gcc documentation ( https://gcc.gnu.org/projects/cxx-status.html ) states
> that "Some C++17 features are available since GCC 5, but support was
> experimental and the ABI of C++17 features was not stable until GCC 9".
>
> Consequently, the NEWS item mentions gcc 9 as an example compiler to use.
>
> My understanding of using gcc 5-8 is that it works as long as gdb doesn't use
> not yet available language features. Of course the set of used language
> features may change in time, so what compiler still works may change.
>
> Problems can arise when shared libs starts to have C++17 based APIs (or
> somehow expose instantiations of such classes). If compiled with a compiler
> in which c++17 support was still experimental, it may be incompatible when
> linking with:
> - code compiled with a compiler with non-experimental c++17 support, or
> - code compiled with a different compiler with experimental c++17 support.
>
> Looking at the current implementation of our only shared lib:
> libinproctrace.so, I couldn't spot any c++ usage in the API, so I'm assuming
> this problem is not likely to happen.
>
> Requiring c++17 means we can drop some code:
> ...
> $ find gdb* -type f \
> | egrep -v "/configure|\.m4" \
> | xargs grep "# *if.*__cplusplus.*2014"
> gdb/cp-support.c:#if __cplusplus >= 201402L
> gdb/dwarf2/cooked-index.c:#if __cplusplus >= 201402L
> gdbsupport/gdb_optional.h:#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
> gdbsupport/gdb_optional.h:#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
> gdbsupport/gdb_unique_ptr.h:#if __cplusplus >= 201402L
> gdbsupport/array-view.h:#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
> gdbsupport/array-view.h:#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
> gdbsupport/array-view.h:#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
> $ find gdb* -type f \
> | egrep -v "/configure|\.m4" \
> | xargs grep "# *if.*__cplusplus.*2017"
> gdb/unittests/string_view-selftests.c:#if __cplusplus < 201703L
> gdb/disasm.h:#if __cplusplus >= 201703L
> gdbsupport/invoke-result.h:#if __cplusplus >= 201703L
> gdbsupport/gdb_string_view.h:#if __cplusplus >= 201703L
> ...
> but that's not yet included in this patch.
If this patch is accepted, one change I'd like is to do is drop
gdb::make_unique, because 1) the current fallback we have for C++11
compilers is not entirely compatible with std::make_unique (the T[] case
is not supported properly I think), and 2) it is not widely used yet, so
"it's not too late" :D
Best,
Lancelot.
>
> Tested on x86_64-linux.
> ---
> gdb/NEWS | 3 +
> gdb/configure | 2030 ++++++++++++++++++++++++++++++++++-----
> gdb/configure.ac | 4 +-
> gdbserver/configure | 2018 +++++++++++++++++++++++++++++++++-----
> gdbserver/configure.ac | 4 +-
> gdbsupport/configure | 2018 +++++++++++++++++++++++++++++++++-----
> gdbsupport/configure.ac | 4 +-
> 7 files changed, 5391 insertions(+), 690 deletions(-)
[-- Attachment #2: 0001-gdb-ax_cxx_compile_stdcxx.m4-upgrade.patch --]
[-- Type: text/x-diff, Size: 22819 bytes --]
From addad71b1b2cc74b05c79a8cd87bb824ef39429e Mon Sep 17 00:00:00 2001
From: Lancelot Six <lancelot.six@amd.com>
Date: Tue, 12 Sep 2023 13:13:23 +0000
Subject: [PATCH] gdb/ax_cxx_compile_stdcxx.m4: upgrade
This patch upgrades gdb/ax_cxx_compile_stdcxx.m4 to follow changes
available in [1] and regenerates the configure script.
[1] https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
Change-Id: I5b16adc65c9e48a13ad65202d58ab7a9d487214e
---
gdb/ax_cxx_compile_stdcxx.m4 | 126 +++++++++++++++++++++++------------
gdb/configure | 44 +++++++++---
gdbserver/configure | 44 +++++++++---
gdbsupport/configure | 44 +++++++++---
4 files changed, 184 insertions(+), 74 deletions(-)
diff --git a/gdb/ax_cxx_compile_stdcxx.m4 b/gdb/ax_cxx_compile_stdcxx.m4
index 68ff8a553f0..b0432599489 100644
--- a/gdb/ax_cxx_compile_stdcxx.m4
+++ b/gdb/ax_cxx_compile_stdcxx.m4
@@ -19,13 +19,13 @@
#
# Check for baseline language coverage in the compiler for the specified
# version of the C++ standard. If necessary, add switches to CXX and
-# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
-# or '14' (for the C++14 standard).
+# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for
+# the respective C++ standard version.
#
# The second argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
# -std=c++11). If neither is specified, you get whatever works, with
-# preference for an extended mode.
+# preference for no added switch, and then for an extended mode.
#
# The third argument, if specified 'mandatory' or if left unspecified,
# indicates that baseline support for the specified C++ standard is
@@ -42,14 +42,17 @@
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
-# Copyright (c) 2016 Krzesimir Nowak <qdlacz@gmail.com>
+# Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
+# Copyright (c) 2019 Enji Cooper <yaneurabeya@gmail.com>
+# Copyright (c) 2020 Jason Merrill <jason@redhat.com>
+# Copyright (c) 2021 Jörn Heusipp <osmanx@problemloesungsmaschine.de>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 8
+#serial 18
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl (serial version number 13).
@@ -58,6 +61,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
+ [$1], [20], [ax_cxx_compile_alternatives="20"],
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [],
[$2], [ext], [],
@@ -70,14 +74,16 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
AC_LANG_PUSH([C++])dnl
CXX_DIALECT=""
ac_success=no
- AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
- ax_cv_cxx_compile_cxx$1,
- [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
- [ax_cv_cxx_compile_cxx$1=yes],
- [ax_cv_cxx_compile_cxx$1=no])])
- if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
- ac_success=yes
- fi
+
+ m4_if([$2], [], [dnl
+ AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
+ ax_cv_cxx_compile_cxx$1,
+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
+ [ax_cv_cxx_compile_cxx$1=yes],
+ [ax_cv_cxx_compile_cxx$1=no])])
+ if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
+ ac_success=yes
+ fi])
m4_if([$2], [noext], [], [dnl
if test x$ac_success = xno; then
@@ -109,9 +115,18 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
dnl HP's aCC needs +std=c++11 according to:
dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
dnl Cray's crayCC needs "-h std=c++11"
+ dnl MSVC needs -std:c++NN for C++17 and later (default is C++14)
for alternative in ${ax_cxx_compile_alternatives}; do
- for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
- cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
+ for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
+ if test x"$switch" = xMSVC; then
+ dnl AS_TR_SH maps both `:` and `=` to `_` so -std:c++17 would collide
+ dnl with -std=c++17. We suffix the cache variable name with _MSVC to
+ dnl avoid this.
+ switch=-std:c++${alternative}
+ cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_${switch}_MSVC])
+ else
+ cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
+ fi
AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
$cachevar,
[ac_save_CXX="$CXX"
@@ -160,7 +175,6 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
)
-
dnl Test body for checking C++14 support
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
@@ -168,12 +182,24 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
)
+dnl Test body for checking C++17 support
+
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
)
+dnl Test body for checking C++20 support
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20],
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_17
+ _AX_CXX_COMPILE_STDCXX_testbody_new_in_20
+)
+
+
dnl Tests for new features in C++11
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
@@ -185,7 +211,11 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
#error "This is not a C++ compiler"
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
#error "This is not a C++11 compiler"
@@ -210,11 +240,13 @@ namespace cxx11
struct Base
{
+ virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
+ virtual ~Derived() override {}
virtual void f() override {}
};
@@ -474,7 +506,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
#error "This is not a C++ compiler"
-#elif __cplusplus < 201402L
+#elif __cplusplus < 201402L && !defined _MSC_VER
#error "This is not a C++14 compiler"
@@ -598,20 +630,12 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
#error "This is not a C++ compiler"
-#elif __cplusplus <= 201402L
+#elif __cplusplus < 201703L && !defined _MSC_VER
#error "This is not a C++17 compiler"
#else
-#if defined(__clang__)
- #define REALLY_CLANG
-#else
- #if defined(__GNUC__)
- #define REALLY_GCC
- #endif
-#endif
-
#include <initializer_list>
#include <utility>
#include <type_traits>
@@ -619,16 +643,12 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
namespace cxx17
{
-#if !defined(REALLY_CLANG)
namespace test_constexpr_lambdas
{
- // TODO: test it with clang++ from git
-
constexpr int foo = [](){return 42;}();
}
-#endif // !defined(REALLY_CLANG)
namespace test::nested_namespace::definitions
{
@@ -863,12 +883,9 @@ namespace cxx17
}
-#if !defined(REALLY_CLANG)
namespace test_template_argument_deduction_for_class_templates
{
- // TODO: test it with clang++ from git
-
template <typename T1, typename T2>
struct pair
{
@@ -887,7 +904,6 @@ namespace cxx17
}
}
-#endif // !defined(REALLY_CLANG)
namespace test_non_type_auto_template_parameters
{
@@ -901,12 +917,9 @@ namespace cxx17
}
-#if !defined(REALLY_CLANG)
namespace test_structured_bindings
{
- // TODO: test it with clang++ from git
-
int arr[2] = { 1, 2 };
std::pair<int, int> pr = { 1, 2 };
@@ -938,14 +951,10 @@ namespace cxx17
const auto [ x3, y3 ] = f3();
}
-#endif // !defined(REALLY_CLANG)
-#if !defined(REALLY_CLANG)
namespace test_exception_spec_type_system
{
- // TODO: test it with clang++ from git
-
struct Good {};
struct Bad {};
@@ -963,7 +972,6 @@ namespace cxx17
static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
}
-#endif // !defined(REALLY_CLANG)
namespace test_inline_variables
{
@@ -988,6 +996,36 @@ namespace cxx17
} // namespace cxx17
-#endif // __cplusplus <= 201402L
+#endif // __cplusplus < 201703L && !defined _MSC_VER
+
+]])
+
+
+dnl Tests for new features in C++20
+
+m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
+
+#ifndef __cplusplus
+
+#error "This is not a C++ compiler"
+
+#elif __cplusplus < 202002L && !defined _MSC_VER
+
+#error "This is not a C++20 compiler"
+
+#else
+
+#include <version>
+
+namespace cxx20
+{
+
+// As C++20 supports feature test macros in the standard, there is no
+// immediate need to actually test for feature availability on the
+// Autoconf side.
+
+} // namespace cxx20
+
+#endif // __cplusplus < 202002L && !defined _MSC_VER
]])
diff --git a/gdb/configure b/gdb/configure
index 2d07e0cb596..df17060bf39 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -16497,7 +16497,8 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
CXX_DIALECT=""
ac_success=no
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; }
if ${ax_cv_cxx_compile_cxx11+:} false; then :
$as_echo_n "(cached) " >&6
@@ -16513,7 +16514,11 @@ else
#error "This is not a C++ compiler"
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
#error "This is not a C++11 compiler"
@@ -16538,11 +16543,13 @@ namespace cxx11
struct Base
{
+ virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
+ virtual ~Derived() override {}
virtual void f() override {}
};
@@ -16800,9 +16807,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5
$as_echo "$ax_cv_cxx_compile_cxx11" >&6; }
- if test x$ax_cv_cxx_compile_cxx11 = xyes; then
- ac_success=yes
- fi
+ if test x$ax_cv_cxx_compile_cxx11 = xyes; then
+ ac_success=yes
+ fi
if test x$ac_success = xno; then
for alternative in ${ax_cxx_compile_alternatives}; do
@@ -16826,7 +16833,11 @@ else
#error "This is not a C++ compiler"
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
#error "This is not a C++11 compiler"
@@ -16851,11 +16862,13 @@ namespace cxx11
struct Base
{
+ virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
+ virtual ~Derived() override {}
virtual void f() override {}
};
@@ -17128,9 +17141,14 @@ $as_echo "$ac_res" >&6; }
fi
if test x$ac_success = xno; then
- for alternative in ${ax_cxx_compile_alternatives}; do
- for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
- cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
+ for alternative in ${ax_cxx_compile_alternatives}; do
+ for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
+ if test x"$switch" = xMSVC; then
+ switch=-std:c++${alternative}
+ cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh`
+ else
+ cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
+ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
if eval \${$cachevar+:} false; then :
@@ -17149,7 +17167,11 @@ else
#error "This is not a C++ compiler"
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
#error "This is not a C++11 compiler"
@@ -17174,11 +17196,13 @@ namespace cxx11
struct Base
{
+ virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
+ virtual ~Derived() override {}
virtual void f() override {}
};
diff --git a/gdbserver/configure b/gdbserver/configure
index e807c60c08a..dc2f4146713 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -5018,7 +5018,8 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
CXX_DIALECT=""
ac_success=no
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; }
if ${ax_cv_cxx_compile_cxx11+:} false; then :
$as_echo_n "(cached) " >&6
@@ -5034,7 +5035,11 @@ else
#error "This is not a C++ compiler"
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
#error "This is not a C++11 compiler"
@@ -5059,11 +5064,13 @@ namespace cxx11
struct Base
{
+ virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
+ virtual ~Derived() override {}
virtual void f() override {}
};
@@ -5321,9 +5328,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5
$as_echo "$ax_cv_cxx_compile_cxx11" >&6; }
- if test x$ax_cv_cxx_compile_cxx11 = xyes; then
- ac_success=yes
- fi
+ if test x$ax_cv_cxx_compile_cxx11 = xyes; then
+ ac_success=yes
+ fi
if test x$ac_success = xno; then
for alternative in ${ax_cxx_compile_alternatives}; do
@@ -5347,7 +5354,11 @@ else
#error "This is not a C++ compiler"
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
#error "This is not a C++11 compiler"
@@ -5372,11 +5383,13 @@ namespace cxx11
struct Base
{
+ virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
+ virtual ~Derived() override {}
virtual void f() override {}
};
@@ -5649,9 +5662,14 @@ $as_echo "$ac_res" >&6; }
fi
if test x$ac_success = xno; then
- for alternative in ${ax_cxx_compile_alternatives}; do
- for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
- cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
+ for alternative in ${ax_cxx_compile_alternatives}; do
+ for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
+ if test x"$switch" = xMSVC; then
+ switch=-std:c++${alternative}
+ cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh`
+ else
+ cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
+ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
if eval \${$cachevar+:} false; then :
@@ -5670,7 +5688,11 @@ else
#error "This is not a C++ compiler"
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
#error "This is not a C++11 compiler"
@@ -5695,11 +5717,13 @@ namespace cxx11
struct Base
{
+ virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
+ virtual ~Derived() override {}
virtual void f() override {}
};
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 9433ac41468..08531fcbed5 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -5916,7 +5916,8 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
CXX_DIALECT=""
ac_success=no
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5
$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; }
if ${ax_cv_cxx_compile_cxx11+:} false; then :
$as_echo_n "(cached) " >&6
@@ -5932,7 +5933,11 @@ else
#error "This is not a C++ compiler"
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
#error "This is not a C++11 compiler"
@@ -5957,11 +5962,13 @@ namespace cxx11
struct Base
{
+ virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
+ virtual ~Derived() override {}
virtual void f() override {}
};
@@ -6219,9 +6226,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5
$as_echo "$ax_cv_cxx_compile_cxx11" >&6; }
- if test x$ax_cv_cxx_compile_cxx11 = xyes; then
- ac_success=yes
- fi
+ if test x$ax_cv_cxx_compile_cxx11 = xyes; then
+ ac_success=yes
+ fi
if test x$ac_success = xno; then
for alternative in ${ax_cxx_compile_alternatives}; do
@@ -6245,7 +6252,11 @@ else
#error "This is not a C++ compiler"
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
#error "This is not a C++11 compiler"
@@ -6270,11 +6281,13 @@ namespace cxx11
struct Base
{
+ virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
+ virtual ~Derived() override {}
virtual void f() override {}
};
@@ -6547,9 +6560,14 @@ $as_echo "$ac_res" >&6; }
fi
if test x$ac_success = xno; then
- for alternative in ${ax_cxx_compile_alternatives}; do
- for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
- cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
+ for alternative in ${ax_cxx_compile_alternatives}; do
+ for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do
+ if test x"$switch" = xMSVC; then
+ switch=-std:c++${alternative}
+ cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_${switch}_MSVC" | $as_tr_sh`
+ else
+ cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh`
+ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5
$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; }
if eval \${$cachevar+:} false; then :
@@ -6568,7 +6586,11 @@ else
#error "This is not a C++ compiler"
-#elif __cplusplus < 201103L
+// MSVC always sets __cplusplus to 199711L in older versions; newer versions
+// only set it correctly if /Zc:__cplusplus is specified as well as a
+// /std:c++NN switch:
+// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
+#elif __cplusplus < 201103L && !defined _MSC_VER
#error "This is not a C++11 compiler"
@@ -6593,11 +6615,13 @@ namespace cxx11
struct Base
{
+ virtual ~Base() {}
virtual void f() {}
};
struct Derived : public Base
{
+ virtual ~Derived() override {}
virtual void f() override {}
};
--
2.34.1
next prev parent reply other threads:[~2023-10-05 10:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 6:54 [RFC] [gdb/build] " Tom de Vries
2023-10-05 10:33 ` Lancelot SIX [this message]
2023-10-05 12:26 ` [PATCH RFC] " Andrew Burgess
2023-10-05 14:26 ` Lancelot SIX
2023-10-05 14:32 ` Simon Marchi
2023-10-05 14:55 ` Lancelot SIX
2023-10-09 14:32 ` Andrew Burgess
2023-10-05 15:55 ` Tom Tromey
2023-10-12 17:30 ` Pedro Alves
2023-10-05 15:31 ` [RFC] [gdb/build] " Tom Tromey
2023-10-10 17:39 ` Tom Tromey
2023-10-10 19:16 ` Simon Marchi
2023-10-12 17:10 ` Pedro Alves
2023-10-12 17:22 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231005103354.5loeki67slszfrcy@hpe6u-23 \
--to=lancelot.six@amd.com \
--cc=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).