From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2080.outbound.protection.outlook.com [40.107.96.80]) by sourceware.org (Postfix) with ESMTPS id D31063858CDB for ; Thu, 5 Oct 2023 10:34:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D31063858CDB Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HmDn6hYT9OEc36dP3j2TomLxRj8RtPk7P3QENikPYLGvGNKitdldVva+yer6sYZXPXAChSUOYJiXkpU88481qnhstnYff+Qdve1mRoQjMWJpYqZlSL4NU7M/HCbYjXPN0+F5nJyK6JDoKLpcCZ8v9UnleBLKz57M/UMUPEUT64Wi9JdeyN5fxuZ+2LzR2IsdizHJSd3ARw8KqWxUAMY3OIi47ikm/Faa9OH5t3LbnqAYCtK8jPanSN1Fp/PWkBWdlh84HqNl0DNGTZaIVEYVB1Qma20+T7jCMg5zsjzAL0Bp4g1gYq/hKBtQV8INZcfWGK7PIhDPKpe+ayE0ca4Y6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5F5l4P3Ys2OnHMMNGEHqOVvIqM0qePXqetf0/Zbbuhs=; b=n1Aa5LAz7iIlrnUnJV8Pqkyv0bVQU8kPAIeQcu/mXS9dYYTxZTZ4UAusrZUCQPutocG1s0K8qMGSkTrSGI/gnQiyzSwJtvm/aiN+PbAajXYO2AjFhVGEaq3krxNg807MJh0Wm1EXxaPl6nW8roYiHgqfppMzozooH6ZTDIS1vrwybi8xsxauPki4TeLUKt34cq1ItenkytOc99gvT0gmVJnGZQPEer+JWec0cNhq161ebRKZ2FPvyIIALHFvK0Imd4Bht0Be0CvhhhNXbIV7tQsQebVqoh69wyjq/iUAoqVokw84xf4JsHi0ZVHuerEmfE6Q2tOiZhy9zyBcjuyt6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5F5l4P3Ys2OnHMMNGEHqOVvIqM0qePXqetf0/Zbbuhs=; b=p2hbOZkUTFlC8mB5ZvMWlzOCbW+AIu6Mab9comudLh5RWGfO5eMxO4dWcDsOkML6FGU6mXulfY9etAWpFGcV18vYxn1cd1kSzB5MgPh/xSn7IhvRQXnJSIQsmKaLeGtfo9Xlys0PDchqqIAdBZ5PeniT2by3V87CO22bDR3piAg= Received: from DS7PR03CA0350.namprd03.prod.outlook.com (2603:10b6:8:55::27) by DM4PR12MB5748.namprd12.prod.outlook.com (2603:10b6:8:5f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.25; Thu, 5 Oct 2023 10:34:27 +0000 Received: from DS2PEPF00003446.namprd04.prod.outlook.com (2603:10b6:8:55:cafe::c0) by DS7PR03CA0350.outlook.office365.com (2603:10b6:8:55::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.34 via Frontend Transport; Thu, 5 Oct 2023 10:34:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF00003446.mail.protection.outlook.com (10.167.17.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Thu, 5 Oct 2023 10:34:27 +0000 Received: from hpe6u-23 (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 5 Oct 2023 05:34:26 -0500 Date: Thu, 5 Oct 2023 10:33:54 +0000 From: Lancelot SIX To: Tom de Vries CC: Subject: Re: [PATCH RFC] Require c++17 compiler Message-ID: <20231005103354.5loeki67slszfrcy@hpe6u-23> References: <20231005065449.32643-1-tdevries@suse.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="7bmfp3qkolwxhvnx" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231005065449.32643-1-tdevries@suse.de> X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003446:EE_|DM4PR12MB5748:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e978ddf-01e1-4236-0df0-08dbc58ea67d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vhu3c0NtiMvcmaTqjx9Hk2Cqy9eLgnO6G576aazcYigrYZy0PFjk/f3OIEj9bhmNWcwJab7CE45hFEeBbMmKVlpjy9NGWhg+bihUPcEhS9NlHHL94pT1CTgWLjndMfbprS8QQf4hoeZv2HRBLNKjiZNATiWY0EMy2KDiUmTRh1OK9cYSj0MK3Wrv+oOrWp08RBhkGfQD4QnlI5dwjdNbCAyvQEse6UwVhZqCemsCFBeH8d/C/tw/sb76zpXTA4sHLXWuCyzZTjkQ4r4sElsfoLo55TAVbofFJ0o5AvODnKATAVo8AwGOWGyEaYjisEojuCuDuC6Yhj/h6dmQsC2T82+pXlA7w8l2+anpZPiqZhGNqHhtoNH8AgBXxOHiEBvmV1QEr+HgQpDvXgEeqsW0FGX9ihIIgOWNaLpUeAj/8SHkRBGaeZLCOYIJsKonuHuNxByfUezcaDYg18olI/wx437CXO10TRlHiWVwQF5V5+HaGp9B1pwRZgwMe/Td04vQbm5q7FNSiXW3SuhHZT7zw3f5QjEU/VcG5OAiDF//HMOSEm25szClG2QwDOmYpXicSt35wG1h/SrMlnN07H9GU6rF+WBNFodRR+sJKgN6anoqH8mlpdq8PNCMBJxsFYVxACEAw0khvlJtIbIZTyPcTg85BNi9o8Cu35n84GU1EZDRCq8ohsGQWIMtZsNLKo5nzSHha0ZQ63f0971PF9bWVErvaYeeBZjR1//e45I3jLpmBwU2Rndz1jyeIGx5XCh+8tlJgmAeC6h4M+sN703TcanitkCVYf9Gw2Qpv2dpTtzkla2qIjhP+IrAyznX9tPrzWCcJl3DRfkkH1iUnxQ+bA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(376002)(39860400002)(136003)(346002)(396003)(230922051799003)(82310400011)(186009)(1800799009)(64100799003)(451199024)(40470700004)(36840700001)(46966006)(47076005)(40460700003)(478600001)(966005)(6666004)(36860700001)(83380400001)(16526019)(26005)(336012)(426003)(82740400003)(40480700001)(9686003)(356005)(55016003)(44144004)(33964004)(235185007)(81166007)(33716001)(5660300002)(86362001)(1076003)(2906002)(4326008)(8676002)(41300700001)(8936002)(70206006)(316002)(70586007)(6916009)(36900700001)(2700100001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2023 10:34:27.1517 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e978ddf-01e1-4236-0df0-08dbc58ea67d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003446.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5748 X-Spam-Status: No, score=-15.8 required=5.0 tests=BAYES_00,DKIM_INVALID,DKIM_SIGNED,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_QUARANTINE,KAM_DMARC_STATUS,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --7bmfp3qkolwxhvnx Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit 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(-) --7bmfp3qkolwxhvnx Content-Type: text/x-diff; charset="iso-8859-1" Content-Disposition: attachment; filename="0001-gdb-ax_cxx_compile_stdcxx.m4-upgrade.patch" Content-Transfer-Encoding: 8bit >From addad71b1b2cc74b05c79a8cd87bb824ef39429e Mon Sep 17 00:00:00 2001 From: Lancelot Six 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 # Copyright (c) 2015 Paul Norman # Copyright (c) 2015 Moritz Klammler -# Copyright (c) 2016 Krzesimir Nowak +# Copyright (c) 2016, 2018 Krzesimir Nowak +# Copyright (c) 2019 Enji Cooper +# Copyright (c) 2020 Jason Merrill +# Copyright (c) 2021 Jörn Heusipp # # 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 #include #include @@ -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 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 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); } -#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 + +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 --7bmfp3qkolwxhvnx--