* [pushed] [gdb/build, clang] Fix ignored aligned attribute
@ 2026-06-12 10:41 Tom de Vries
2026-06-12 13:24 ` Tom Tromey
2026-06-12 13:26 ` Pedro Alves
0 siblings, 2 replies; 5+ messages in thread
From: Tom de Vries @ 2026-06-12 10:41 UTC (permalink / raw)
To: gdb-patches
PR build/34279 reports a build failure with clang.
This is a regression since commit 6c85ef111b0 ("[gdb] Use using instead of
typedef"), which did:
...
-typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
+using compat_x32_clock_t = long __attribute__ ((__aligned__ (4)));
...
The problem is that clang ignores the attribute.
Fix this by reverting this part of the commit.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34279
---
gdb/nat/amd64-linux-siginfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
index 8f1e4acc47e..99faccabf37 100644
--- a/gdb/nat/amd64-linux-siginfo.c
+++ b/gdb/nat/amd64-linux-siginfo.c
@@ -203,7 +203,7 @@ struct compat_siginfo_t
};
/* For x32, clock_t in _sigchld is 64bit aligned at 4 bytes. */
-using compat_x32_clock_t = long __attribute__ ((__aligned__ (4)));
+typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
struct __attribute__ ((__aligned__ (8))) compat_x32_siginfo_t
{
base-commit: 4cdc9a9d93571737476034869dd8caaecb5ca35d
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pushed] [gdb/build, clang] Fix ignored aligned attribute
2026-06-12 10:41 [pushed] [gdb/build, clang] Fix ignored aligned attribute Tom de Vries
@ 2026-06-12 13:24 ` Tom Tromey
2026-06-16 7:26 ` Tom de Vries
2026-06-12 13:26 ` Pedro Alves
1 sibling, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2026-06-12 13:24 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> PR build/34279 reports a build failure with clang.
Tom> This is a regression since commit 6c85ef111b0 ("[gdb] Use using instead of
Tom> typedef"), which did:
Tom> ...
Tom> -typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
Tom> +using compat_x32_clock_t = long __attribute__ ((__aligned__ (4)));
Tom> ...
Tom> The problem is that clang ignores the attribute.
Very surprising.
Tom> /* For x32, clock_t in _sigchld is 64bit aligned at 4 bytes. */
Tom> -using compat_x32_clock_t = long __attribute__ ((__aligned__ (4)));
Tom> +typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
I think if we need this to remain a typedef, a comment explaining the
reason would be good.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pushed] [gdb/build, clang] Fix ignored aligned attribute
2026-06-12 10:41 [pushed] [gdb/build, clang] Fix ignored aligned attribute Tom de Vries
2026-06-12 13:24 ` Tom Tromey
@ 2026-06-12 13:26 ` Pedro Alves
2026-06-16 6:27 ` Tom de Vries
1 sibling, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2026-06-12 13:26 UTC (permalink / raw)
To: Tom de Vries, gdb-patches
On 2026-06-12 11:41, Tom de Vries wrote:
> PR build/34279 reports a build failure with clang.
>
> This is a regression since commit 6c85ef111b0 ("[gdb] Use using instead of
> typedef"), which did:
> ...
> -typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
> +using compat_x32_clock_t = long __attribute__ ((__aligned__ (4)));
> ...
>
> The problem is that clang ignores the attribute.
FYI, this form:
using B [[gnu::aligned (4)]] = long;
works the same with gcc and clang.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pushed] [gdb/build, clang] Fix ignored aligned attribute
2026-06-12 13:26 ` Pedro Alves
@ 2026-06-16 6:27 ` Tom de Vries
0 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-06-16 6:27 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
On 6/12/26 3:26 PM, Pedro Alves wrote:
> On 2026-06-12 11:41, Tom de Vries wrote:
>> PR build/34279 reports a build failure with clang.
>>
>> This is a regression since commit 6c85ef111b0 ("[gdb] Use using instead of
>> typedef"), which did:
>> ...
>> -typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
>> +using compat_x32_clock_t = long __attribute__ ((__aligned__ (4)));
>> ...
>>
>> The problem is that clang ignores the attribute.
>
> FYI, this form:
>
> using B [[gnu::aligned (4)]] = long;
>
> works the same with gcc and clang.
>
Hi Pedro,
thanks for this suggestion.
I've used this approach in a follow-up patch (
https://sourceware.org/pipermail/gdb-patches/2026-June/228041.html ).
Thanks,
- Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pushed] [gdb/build, clang] Fix ignored aligned attribute
2026-06-12 13:24 ` Tom Tromey
@ 2026-06-16 7:26 ` Tom de Vries
0 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-06-16 7:26 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches, Pedro Alves
On 6/12/26 3:24 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> PR build/34279 reports a build failure with clang.
> Tom> This is a regression since commit 6c85ef111b0 ("[gdb] Use using instead of
> Tom> typedef"), which did:
> Tom> ...
> Tom> -typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
> Tom> +using compat_x32_clock_t = long __attribute__ ((__aligned__ (4)));
> Tom> ...
>
> Tom> The problem is that clang ignores the attribute.
>
> Very surprising.
>
> Tom> /* For x32, clock_t in _sigchld is 64bit aligned at 4 bytes. */
> Tom> -using compat_x32_clock_t = long __attribute__ ((__aligned__ (4)));
> Tom> +typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
>
> I think if we need this to remain a typedef, a comment explaining the
> reason would be good.
I ended up using a suggestion of Pedro (
https://sourceware.org/pipermail/gdb-patches/2026-June/228041.html ):
...
-typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
+using compat_x32_clock_t [[gnu::aligned (4)]] = long;
...
so I guess such a comment is not needed.
FWIW and FTR, I also looked into other ways to fix this.
Using the packed template works:
...
diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
index 99faccabf37..30a1107d3ea 100644
--- a/gdb/nat/amd64-linux-siginfo.c
+++ b/gdb/nat/amd64-linux-siginfo.c
@@ -18,6 +18,7 @@
along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <signal.h>
+#include "gdbsupport/packed.h"
#include "amd64-linux-siginfo.h"
#define GDB_SI_SIZE 128
@@ -202,9 +203,6 @@ struct compat_siginfo_t
} _sifields;
};
-/* For x32, clock_t in _sigchld is 64bit aligned at 4 bytes. */
-typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
-
struct __attribute__ ((__aligned__ (8))) compat_x32_siginfo_t
{
int si_signo;
@@ -244,8 +242,8 @@ struct __attribute__ ((__aligned__ (8)))
compat_x32_siginfo_t
unsigned int _pid;
unsigned int _uid;
int _status;
- compat_x32_clock_t _utime;
- compat_x32_clock_t _stime;
+ packed<long> _utime;
+ packed<long> _stime;
} _sigchld;
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
@@ -478,10 +476,8 @@ compat_x32_siginfo_from_siginfo
(compat_x32_siginfo_t *to,
to->cpt_si_pid = from_ptrace.cpt_si_pid;
to->cpt_si_uid = from_ptrace.cpt_si_uid;
to->cpt_si_status = from_ptrace.cpt_si_status;
- memcpy (&to->cpt_si_utime, &from_ptrace.cpt_si_utime,
- sizeof (to->cpt_si_utime));
- memcpy (&to->cpt_si_stime, &from_ptrace.cpt_si_stime,
- sizeof (to->cpt_si_stime));
+ to->cpt_si_utime = from_ptrace.cpt_si_utime;
+ to->cpt_si_stime = from_ptrace.cpt_si_stime;
break;
case SIGILL:
case SIGFPE:
...
Likewise, tagging the struct with attribute packed:
...
diff --git a/gdb/nat/amd64-linux-siginfo.c b/gdb/nat/amd64-linux-siginfo.c
index 99faccabf37..8279acd4117 100644
--- a/gdb/nat/amd64-linux-siginfo.c
+++ b/gdb/nat/amd64-linux-siginfo.c
@@ -202,9 +202,6 @@ struct compat_siginfo_t
} _sifields;
};
-/* For x32, clock_t in _sigchld is 64bit aligned at 4 bytes. */
-typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
-
struct __attribute__ ((__aligned__ (8))) compat_x32_siginfo_t
{
int si_signo;
@@ -239,13 +236,13 @@ struct __attribute__ ((__aligned__ (8)))
compat_x32_siginfo_t
} _rt;
/* SIGCHLD */
- struct
+ struct __attribute__((packed))
{
unsigned int _pid;
unsigned int _uid;
int _status;
- compat_x32_clock_t _utime;
- compat_x32_clock_t _stime;
+ long _utime;
+ long _stime;
} _sigchld;
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
...
Thanks,
- Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-16 7:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-12 10:41 [pushed] [gdb/build, clang] Fix ignored aligned attribute Tom de Vries
2026-06-12 13:24 ` Tom Tromey
2026-06-16 7:26 ` Tom de Vries
2026-06-12 13:26 ` Pedro Alves
2026-06-16 6:27 ` Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox