From patchwork Wed Feb 21 16:46:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 86174 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B5183858402 for ; Wed, 21 Feb 2024 16:47:43 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 5918E3858C52 for ; Wed, 21 Feb 2024 16:47:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5918E3858C52 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5918E3858C52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708534033; cv=none; b=AzKBvuqFoNSLYNa+6C1Lcm47s5SGsWdNIDapPuCwhW77SDJ24lzJUOyhkpoRO0Rezc9oy7UAIDl2f7ZSx1mM8+QPuPXYJCi8aQw18nppiXBlj71SGeiJGsthWyrYrYoTx0P172hscokM/gRctxPxTLUuZM/39kDKRFux4GxFX3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708534033; c=relaxed/simple; bh=tNi9Nb8v691R1cyy0N2+5bQysuVI93IRsqmsaio3EQ0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=eQioxXvaw3IDvGSXoFr4jLIm0+vB8EazpO+vzyvxoE2beI4axMD8gR5km1qTQ0GaHXCivxmTn/jzhOj+4ddSl5V02VrWDdeh2nuPnP1oqWVDs96ZGEmEgHIoAhrbp4Idxcz1eZzOBuAekeeFvCKFuuv1E5WIc35rRgxR615g2S4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost.localdomain (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id CB33D1E030; Wed, 21 Feb 2024 11:47:10 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 1/2] gdb: remove some GCC version checks Date: Wed, 21 Feb 2024 11:46:51 -0500 Message-ID: <20240221164709.54212-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1173.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org New in v2: - remove changes to nat/x86-gcc-cpuid.h - adjust indentation in tracepoint.h Since we now require C++17, and therefore gcc >= 9, it's no longer useful to have gcc version checks for older gcc version. Change-Id: I3a87baa03c475f2b847b422b16b69c5ff7215b54 Reviewed-by: Kevin Buettner --- gdb/unittests/enum-flags-selftests.c | 6 ------ gdbserver/tracepoint.h | 6 +----- gdbsupport/common-defs.h | 9 --------- 3 files changed, 1 insertion(+), 20 deletions(-) base-commit: 99eeecc8d276e5af745e48825d66efff693a7678 diff --git a/gdb/unittests/enum-flags-selftests.c b/gdb/unittests/enum-flags-selftests.c index 853ebca37823..607b8ac66a64 100644 --- a/gdb/unittests/enum-flags-selftests.c +++ b/gdb/unittests/enum-flags-selftests.c @@ -253,10 +253,8 @@ CHECK_VALID (true, EF, true ? RE () : EF ()) CHECK_VALID (true, int, true ? EF () : EF2 ()) CHECK_VALID (true, int, true ? EF2 () : EF ()) -#if GCC_VERSION >= 5003 || defined __clang__ CHECK_VALID (true, int, true ? EF () : RE2 ()) CHECK_VALID (true, int, true ? RE2 () : EF ()) -#endif /* Same, but with an unsigned enum. */ @@ -264,10 +262,8 @@ typedef unsigned int uns; CHECK_VALID (true, uns, true ? EF () : UEF ()) CHECK_VALID (true, uns, true ? UEF () : EF ()) -#if GCC_VERSION >= 5003 || defined __clang__ CHECK_VALID (true, uns, true ? EF () : URE ()) CHECK_VALID (true, uns, true ? URE () : EF ()) -#endif /* Unfortunately this can't work due to the way C++ computes the return type of the ternary conditional operator. int isn't @@ -279,10 +275,8 @@ CHECK_VALID (true, uns, true ? URE () : EF ()) error: operands to ?: have different types ‘enum_flags’ and ‘int’ Confirmed to work with gcc 4.9, 5.3 and clang 3.7. */ -#if GCC_VERSION >= 4009 || defined __clang__ CHECK_VALID (false, void, true ? EF () : 0) CHECK_VALID (false, void, true ? 0 : EF ()) -#endif /* Check that the ++/--/<>/<<=/>>= operators are deleted. */ diff --git a/gdbserver/tracepoint.h b/gdbserver/tracepoint.h index 8b232324d2ec..1660c9445ee5 100644 --- a/gdbserver/tracepoint.h +++ b/gdbserver/tracepoint.h @@ -38,11 +38,7 @@ void initialize_tracepoint (void); #if defined _WIN32 || defined __CYGWIN__ # define EXPORTED_SYMBOL __declspec (dllexport) #else -# if __GNUC__ >= 4 -# define EXPORTED_SYMBOL __attribute__ ((visibility ("default"))) -# else -# define EXPORTED_SYMBOL -# endif +# define EXPORTED_SYMBOL __attribute__ ((visibility ("default"))) #endif /* Use these to make sure the functions and variables the IPA needs to diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h index 8ec559e9b680..6120719480b8 100644 --- a/gdbsupport/common-defs.h +++ b/gdbsupport/common-defs.h @@ -187,17 +187,8 @@ #undef ATTRIBUTE_NONNULL #define ATTRIBUTE_NONNULL(m) -#if GCC_VERSION >= 3004 #define ATTRIBUTE_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) -#else -#define ATTRIBUTE_UNUSED_RESULT -#endif - -#if (GCC_VERSION > 4000) #define ATTRIBUTE_USED __attribute__ ((__used__)) -#else -#define ATTRIBUTE_USED -#endif #include "libiberty.h" #include "pathmax.h" From patchwork Wed Feb 21 16:46:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 86175 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 915FF385840C for ; Wed, 21 Feb 2024 16:47:44 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id E6D8C3858C53 for ; Wed, 21 Feb 2024 16:47:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E6D8C3858C53 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E6D8C3858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708534034; cv=none; b=PI7w1LgsLPGpdtXz4eHMNgapnClItDUmOXg/UY6jWjRKs8GNV3WFV79HRMcHqz6E2/Oujw3P2n2FMRbUdfxwuHKFg3XudIPcp67DqqfcL9kpwJSgH6s3bkIhnqo9t+6GytYM6SwTugRJmk8WzfMRAugWUui3Kxlu/AkeCS/rQXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708534034; c=relaxed/simple; bh=l6eY9JlUCmcPZxOGdsUTVY1mZrvb8mB7nig3IY8IQqI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=WXE+fgSnZhxIMj76LK5tn2I0TV1kU7xykkRd8ZIGwNtMYGEQf4RxdaZbHc+pdieQ2vVvDye4cGfO0s2DyeT+EF+vW5uFmDUHm7Uw+3HHANzh9E7VxllQ1TSbXyvOsyoEy4lVB+YA/SSSyDxVtKgW3VYd80Sgp8eonv9OEDu5lF8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost.localdomain (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 2CE2E1E0C1; Wed, 21 Feb 2024 11:47:11 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 2/2] gdbsupport: assume that compiler supports std::{is_trivially_constructible, is_trivially_copyable} Date: Wed, 21 Feb 2024 11:46:52 -0500 Message-ID: <20240221164709.54212-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240221164709.54212-1-simon.marchi@efficios.com> References: <20240221164709.54212-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1173.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This code was there to support g++ 4, which didn't support std::is_trivially_constructible and std::is_trivially_copyable. Since we now require g++ >= 9, I think it's fair to assume that GDB will always be compiled with a compiler that supports those. Change-Id: Ie7c1649139a2f48bf662cac92d7f3e38fb1f1ba1 --- gdb/trad-frame.c | 2 -- gdb/unittests/array-view-selftests.c | 4 ---- gdb/unittests/enum-flags-selftests.c | 4 ---- gdb/unittests/packed-selftests.c | 4 ---- gdbsupport/check-defines.el | 2 -- gdbsupport/packed.h | 2 -- gdbsupport/poison.h | 8 -------- gdbsupport/traits.h | 21 --------------------- 8 files changed, 47 deletions(-) diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c index 8b63927b133c..c35e08ab2805 100644 --- a/gdb/trad-frame.c +++ b/gdb/trad-frame.c @@ -61,9 +61,7 @@ trad_frame_reset_saved_regs (struct gdbarch *gdbarch, trad_frame_saved_reg * trad_frame_alloc_saved_regs (struct gdbarch *gdbarch) { -#ifdef HAVE_IS_TRIVIALLY_CONSTRUCTIBLE static_assert (std::is_trivially_constructible::value); -#endif int numregs = gdbarch_num_cooked_regs (gdbarch); trad_frame_saved_reg *this_saved_regs diff --git a/gdb/unittests/array-view-selftests.c b/gdb/unittests/array-view-selftests.c index 9d2448fefc10..299318ace434 100644 --- a/gdb/unittests/array-view-selftests.c +++ b/gdb/unittests/array-view-selftests.c @@ -30,15 +30,11 @@ namespace array_view_tests { #define CHECK_TRAIT(TRAIT) \ static_assert (std::TRAIT>::value, "") -#if HAVE_IS_TRIVIALLY_COPYABLE - CHECK_TRAIT (is_trivially_copyable); CHECK_TRAIT (is_trivially_move_assignable); CHECK_TRAIT (is_trivially_move_constructible); CHECK_TRAIT (is_trivially_destructible); -#endif - #undef CHECK_TRAIT /* Wrapper around std::is_convertible to make the code using it a bit diff --git a/gdb/unittests/enum-flags-selftests.c b/gdb/unittests/enum-flags-selftests.c index 607b8ac66a64..54e168173de6 100644 --- a/gdb/unittests/enum-flags-selftests.c +++ b/gdb/unittests/enum-flags-selftests.c @@ -63,14 +63,10 @@ DEF_ENUM_FLAGS_TYPE (RE, EF); DEF_ENUM_FLAGS_TYPE (RE2, EF2); DEF_ENUM_FLAGS_TYPE (URE, UEF); -#if HAVE_IS_TRIVIALLY_COPYABLE - /* So that std::vectors of types that have enum_flags fields can reallocate efficiently memcpy. */ static_assert (std::is_trivially_copyable::value); -#endif - /* A couple globals used as lvalues in the CHECK_VALID expressions below. Their names (and types) match the uppercase type names exposed by CHECK_VALID just to make the expressions easier to diff --git a/gdb/unittests/packed-selftests.c b/gdb/unittests/packed-selftests.c index 3f20861ad4a2..852a7d364ce9 100644 --- a/gdb/unittests/packed-selftests.c +++ b/gdb/unittests/packed-selftests.c @@ -46,16 +46,12 @@ static_assert (alignof (packed) == 1); #define CHECK_TRAIT(TRAIT) \ static_assert (std::TRAIT>::value, "") -#if HAVE_IS_TRIVIALLY_COPYABLE - CHECK_TRAIT (is_trivially_copyable); CHECK_TRAIT (is_trivially_copy_constructible); CHECK_TRAIT (is_trivially_move_constructible); CHECK_TRAIT (is_trivially_copy_assignable); CHECK_TRAIT (is_trivially_move_assignable); -#endif - #undef CHECK_TRAIT /* Entry point. */ diff --git a/gdbsupport/check-defines.el b/gdbsupport/check-defines.el index 7603effc29de..b7cf61ba8599 100644 --- a/gdbsupport/check-defines.el +++ b/gdbsupport/check-defines.el @@ -35,8 +35,6 @@ (put (intern "HAVE_USEFUL_SBRK") :check-ok t) (put (intern "HAVE_SOCKETS") :check-ok t) (put (intern "HAVE_F_GETFD") :check-ok t) -(put (intern "HAVE_IS_TRIVIALLY_COPYABLE") :check-ok t) -(put (intern "HAVE_IS_TRIVIALLY_CONSTRUCTIBLE") :check-ok t) (put (intern "HAVE_DOS_BASED_FILE_SYSTEM") :check-ok t) (defun check-read-config.in (file) diff --git a/gdbsupport/packed.h b/gdbsupport/packed.h index 8035535386b0..5c817d4c9cce 100644 --- a/gdbsupport/packed.h +++ b/gdbsupport/packed.h @@ -80,9 +80,7 @@ struct ATTRIBUTE_GCC_STRUCT packed static_assert (alignof (packed) == 1); /* Make sure packed can be wrapped with std::atomic. */ -#if HAVE_IS_TRIVIALLY_COPYABLE static_assert (std::is_trivially_copyable::value); -#endif static_assert (std::is_copy_constructible::value); static_assert (std::is_move_constructible::value); static_assert (std::is_copy_assignable::value); diff --git a/gdbsupport/poison.h b/gdbsupport/poison.h index 0d0159eb7f81..7b4f8e8a178d 100644 --- a/gdbsupport/poison.h +++ b/gdbsupport/poison.h @@ -56,8 +56,6 @@ template >>> void *memset (T *s, int c, size_t n) = delete; -#if HAVE_IS_TRIVIALLY_COPYABLE - /* Similarly, poison memcpy and memmove of non trivially-copyable types, which is undefined. */ @@ -83,17 +81,11 @@ template >>> void *memmove (D *dest, const S *src, size_t n) = delete; -#endif /* HAVE_IS_TRIVIALLY_COPYABLE */ - /* Poison XNEW and friends to catch usages of malloc-style allocations on objects that require new/delete. */ template -#if HAVE_IS_TRIVIALLY_CONSTRUCTIBLE using IsMallocable = std::is_trivially_constructible; -#else -using IsMallocable = std::true_type; -#endif template using IsFreeable = gdb::Or, std::is_void>; diff --git a/gdbsupport/traits.h b/gdbsupport/traits.h index eb97b9659904..92fe59f34af7 100644 --- a/gdbsupport/traits.h +++ b/gdbsupport/traits.h @@ -20,27 +20,6 @@ #include -/* GCC does not understand __has_feature. */ -#if !defined(__has_feature) -# define __has_feature(x) 0 -#endif - -/* HAVE_IS_TRIVIALLY_COPYABLE is defined as 1 iff - std::is_trivially_copyable is available. GCC only implemented it - in GCC 5. */ -#if (__has_feature(is_trivially_copyable) \ - || (defined __GNUC__ && __GNUC__ >= 5)) -# define HAVE_IS_TRIVIALLY_COPYABLE 1 -#endif - -/* HAVE_IS_TRIVIALLY_CONSTRUCTIBLE is defined as 1 iff - std::is_trivially_constructible is available. GCC only implemented it - in GCC 5. */ -#if (__has_feature(is_trivially_constructible) \ - || (defined __GNUC__ && __GNUC__ >= 5)) -# define HAVE_IS_TRIVIALLY_CONSTRUCTIBLE 1 -#endif - namespace gdb { /* Implementation of the detection idiom: