public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] gdb: remove some GCC version checks
@ 2024-02-21  2:19 Simon Marchi
  2024-02-21  2:19 ` [PATCH 2/2] gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable} Simon Marchi
  2024-02-21 15:03 ` [PATCH 1/2] gdb: remove some GCC version checks Pedro Alves
  0 siblings, 2 replies; 4+ messages in thread
From: Simon Marchi @ 2024-02-21  2:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

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
---
 gdb/nat/x86-gcc-cpuid.h              | 17 -----------------
 gdb/unittests/enum-flags-selftests.c |  6 ------
 gdbserver/tracepoint.h               |  4 ----
 gdbsupport/common-defs.h             |  9 ---------
 4 files changed, 36 deletions(-)

diff --git a/gdb/nat/x86-gcc-cpuid.h b/gdb/nat/x86-gcc-cpuid.h
index dfd12587d813..b2eda44a2294 100644
--- a/gdb/nat/x86-gcc-cpuid.h
+++ b/gdb/nat/x86-gcc-cpuid.h
@@ -195,7 +195,6 @@ __get_cpuid_max (unsigned int __ext, unsigned int *__sig)
 
 #ifndef __x86_64__
   /* See if we can use cpuid.  On AMD64 we always can.  */
-#if __GNUC__ >= 3
   __asm__ ("pushf{l|d}\n\t"
 	   "pushf{l|d}\n\t"
 	   "pop{l}\t%0\n\t"
@@ -208,22 +207,6 @@ __get_cpuid_max (unsigned int __ext, unsigned int *__sig)
 	   "popf{l|d}\n\t"
 	   : "=&r" (__eax), "=&r" (__ebx)
 	   : "i" (0x00200000));
-#else
-/* Host GCCs older than 3.0 weren't supporting Intel asm syntax
-   nor alternatives in i386 code.  */
-  __asm__ ("pushfl\n\t"
-	   "pushfl\n\t"
-	   "popl\t%0\n\t"
-	   "movl\t%0, %1\n\t"
-	   "xorl\t%2, %0\n\t"
-	   "pushl\t%0\n\t"
-	   "popfl\n\t"
-	   "pushfl\n\t"
-	   "popl\t%0\n\t"
-	   "popfl\n\t"
-	   : "=&r" (__eax), "=&r" (__ebx)
-	   : "i" (0x00200000));
-#endif
 
   if (!((__eax ^ __ebx) & 0x00200000))
     return 0;
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<RE>’ 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..6369e91aa276 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
 #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"

base-commit: 67db6ada6370f24d344e91c2add203735292534c
-- 
2.43.2


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

* [PATCH 2/2] gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable}
  2024-02-21  2:19 [PATCH 1/2] gdb: remove some GCC version checks Simon Marchi
@ 2024-02-21  2:19 ` Simon Marchi
  2024-02-21 15:03 ` [PATCH 1/2] gdb: remove some GCC version checks Pedro Alves
  1 sibling, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2024-02-21  2:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

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<trad_frame_saved_reg>::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<gdb::array_view<gdb_byte>>::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<EF>::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<test_enum, 4>) == 1);
 #define CHECK_TRAIT(TRAIT)			\
   static_assert (std::TRAIT<packed<test_enum, 1>>::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<packed>::value);
-#endif
     static_assert (std::is_copy_constructible<packed>::value);
     static_assert (std::is_move_constructible<packed>::value);
     static_assert (std::is_copy_assignable<packed>::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 <typename T,
 	  typename = gdb::Requires<gdb::Not<IsMemsettable<T>>>>
 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 <typename D, typename S,
 	  typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
 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<typename T>
-#if HAVE_IS_TRIVIALLY_CONSTRUCTIBLE
 using IsMallocable = std::is_trivially_constructible<T>;
-#else
-using IsMallocable = std::true_type;
-#endif
 
 template<typename T>
 using IsFreeable = gdb::Or<std::is_trivially_destructible<T>, std::is_void<T>>;
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 <type_traits>
 
-/* 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:
-- 
2.43.2


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

* Re: [PATCH 1/2] gdb: remove some GCC version checks
  2024-02-21  2:19 [PATCH 1/2] gdb: remove some GCC version checks Simon Marchi
  2024-02-21  2:19 ` [PATCH 2/2] gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable} Simon Marchi
@ 2024-02-21 15:03 ` Pedro Alves
  2024-02-21 16:45   ` Simon Marchi
  1 sibling, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2024-02-21 15:03 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 2024-02-21 02:19, Simon Marchi wrote:

> 
> diff --git a/gdb/nat/x86-gcc-cpuid.h b/gdb/nat/x86-gcc-cpuid.h
> index dfd12587d813..b2eda44a2294 100644
> --- a/gdb/nat/x86-gcc-cpuid.h
> +++ b/gdb/nat/x86-gcc-cpuid.h
> @@ -195,7 +195,6 @@ __get_cpuid_max (unsigned int __ext, unsigned int *__sig)
>  
>  #ifndef __x86_64__
>    /* See if we can use cpuid.  On AMD64 we always can.  */
> -#if __GNUC__ >= 3
>    __asm__ ("pushf{l|d}\n\t"
>  	   "pushf{l|d}\n\t"
>  	   "pop{l}\t%0\n\t"
> @@ -208,22 +207,6 @@ __get_cpuid_max (unsigned int __ext, unsigned int *__sig)
>  	   "popf{l|d}\n\t"
>  	   : "=&r" (__eax), "=&r" (__ebx)
>  	   : "i" (0x00200000));
> -#else
> -/* Host GCCs older than 3.0 weren't supporting Intel asm syntax
> -   nor alternatives in i386 code.  */
> -  __asm__ ("pushfl\n\t"
> -	   "pushfl\n\t"
> -	   "popl\t%0\n\t"
> -	   "movl\t%0, %1\n\t"
> -	   "xorl\t%2, %0\n\t"
> -	   "pushl\t%0\n\t"
> -	   "popfl\n\t"
> -	   "pushfl\n\t"
> -	   "popl\t%0\n\t"
> -	   "popfl\n\t"
> -	   : "=&r" (__eax), "=&r" (__ebx)
> -	   : "i" (0x00200000));
> -#endif
>  
>    if (!((__eax ^ __ebx) & 0x00200000))
>      return 0;

It would be better IMO to avoid local changes to this file, especially if they're not
really needed:

/*
 * Helper cpuid.h file copied from gcc-6.0.0.  Code in gdb should not
                       ^^^^^^^^^^^^^^^^^^^^^
 * include this directly, but pull in x86-cpuid.h and use that func.
 */

At some point, someone may want to pull a newer version from GCC, and local changes
just make that a little more difficult.

> diff --git a/gdbserver/tracepoint.h b/gdbserver/tracepoint.h
> index 8b232324d2ec..6369e91aa276 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")))

That "#  define" line should be "reindented".

> -# else
> -#  define EXPORTED_SYMBOL
> -# endif
>  #endif



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

* Re: [PATCH 1/2] gdb: remove some GCC version checks
  2024-02-21 15:03 ` [PATCH 1/2] gdb: remove some GCC version checks Pedro Alves
@ 2024-02-21 16:45   ` Simon Marchi
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2024-02-21 16:45 UTC (permalink / raw)
  To: Pedro Alves, Simon Marchi, gdb-patches

On 2/21/24 10:03, Pedro Alves wrote:
> On 2024-02-21 02:19, Simon Marchi wrote:
> 
>>
>> diff --git a/gdb/nat/x86-gcc-cpuid.h b/gdb/nat/x86-gcc-cpuid.h
>> index dfd12587d813..b2eda44a2294 100644
>> --- a/gdb/nat/x86-gcc-cpuid.h
>> +++ b/gdb/nat/x86-gcc-cpuid.h
>> @@ -195,7 +195,6 @@ __get_cpuid_max (unsigned int __ext, unsigned int *__sig)
>>  
>>  #ifndef __x86_64__
>>    /* See if we can use cpuid.  On AMD64 we always can.  */
>> -#if __GNUC__ >= 3
>>    __asm__ ("pushf{l|d}\n\t"
>>  	   "pushf{l|d}\n\t"
>>  	   "pop{l}\t%0\n\t"
>> @@ -208,22 +207,6 @@ __get_cpuid_max (unsigned int __ext, unsigned int *__sig)
>>  	   "popf{l|d}\n\t"
>>  	   : "=&r" (__eax), "=&r" (__ebx)
>>  	   : "i" (0x00200000));
>> -#else
>> -/* Host GCCs older than 3.0 weren't supporting Intel asm syntax
>> -   nor alternatives in i386 code.  */
>> -  __asm__ ("pushfl\n\t"
>> -	   "pushfl\n\t"
>> -	   "popl\t%0\n\t"
>> -	   "movl\t%0, %1\n\t"
>> -	   "xorl\t%2, %0\n\t"
>> -	   "pushl\t%0\n\t"
>> -	   "popfl\n\t"
>> -	   "pushfl\n\t"
>> -	   "popl\t%0\n\t"
>> -	   "popfl\n\t"
>> -	   : "=&r" (__eax), "=&r" (__ebx)
>> -	   : "i" (0x00200000));
>> -#endif
>>  
>>    if (!((__eax ^ __ebx) & 0x00200000))
>>      return 0;
> 
> It would be better IMO to avoid local changes to this file, especially if they're not
> really needed:
> 
> /*
>  * Helper cpuid.h file copied from gcc-6.0.0.  Code in gdb should not
>                        ^^^^^^^^^^^^^^^^^^^^^
>  * include this directly, but pull in x86-cpuid.h and use that func.
>  */
> 
> At some point, someone may want to pull a newer version from GCC, and local changes
> just make that a little more difficult.

I didn't realize this was copied from gcc, despite having "gcc" in the
name.  I'll remove this bit from v2.

>> diff --git a/gdbserver/tracepoint.h b/gdbserver/tracepoint.h
>> index 8b232324d2ec..6369e91aa276 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")))
> 
> That "#  define" line should be "reindented".

Done.

Simon

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

end of thread, other threads:[~2024-02-21 16:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-21  2:19 [PATCH 1/2] gdb: remove some GCC version checks Simon Marchi
2024-02-21  2:19 ` [PATCH 2/2] gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable} Simon Marchi
2024-02-21 15:03 ` [PATCH 1/2] gdb: remove some GCC version checks Pedro Alves
2024-02-21 16:45   ` Simon Marchi

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).