On Wed, Apr 22, 2026 at 06:42:54PM +0100, Leo Yan wrote:
> Building on Debian sid with GCC 15 fails:
> 
>     CC       libc-gcs
>   libc-gcs.c: In function 'ptrace_read_write':
>   libc-gcs.c:142:25: error: storage size of 'child_gcs' isn't known
>     142 |         struct user_gcs child_gcs;
>         |                         ^~~~~~~~~
>   libc-gcs.c:142:25: warning: unused variable 'child_gcs' [-Wunused-variable]
> 
> For GCC-15, NT_ARM_GCS is defined in the libc header, causing gcs-util.h
> to skip its fallback definition of struct user_gcs. This leads to the
> compiler error.
> 
> Fix this by including <asm/ptrace.h> to provide the proper definition.

This is not caused by GCC-15 as it doesn't provide these headers. AFAICT
on Debian we have NT_ARM_GCS coming from glibc and user_gcs from the
kernel asm/ptrace.h uapi header (linux-libc-dev). We also have
NT_ARM_GCS in linux/elf.h as part of the kernel headers.

While the kernel exposed the macro and structure in the same commit, I
don't think it is required distros to align the glibc macro with the
linux headers. Glibc does not even use the kernel's linux/elf.h for the
macros, it just adds the definitions when they turn up in a released
kernel.

So you can have a glibc that defines NT_ARM_GCS but a linux-libc-dev
package that is not up to date to include struct user_gcs.

I think a better fix is to always define struct user_gcs and only
conditionally define NT_ARM_GCS (IOW, move the #endif higher).

-- 
Catalin

Reply via email to