From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org, Pedro Alves <pedro@palves.net>
Subject: Re: [pushed] [gdb/build, clang] Fix ignored aligned attribute
Date: Tue, 16 Jun 2026 09:26:17 +0200 [thread overview]
Message-ID: <c165e2cc-0b27-40e9-addc-3f555e7cd0f2@suse.de> (raw)
In-Reply-To: <874ij7evsh.fsf@tromey.com>
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
next prev parent reply other threads:[~2026-06-16 7:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 10:41 Tom de Vries
2026-06-12 13:24 ` Tom Tromey
2026-06-16 7:26 ` Tom de Vries [this message]
2026-06-12 13:26 ` Pedro Alves
2026-06-16 6:27 ` Tom de Vries
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=c165e2cc-0b27-40e9-addc-3f555e7cd0f2@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=pedro@palves.net \
--cc=tom@tromey.com \
/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