public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2] kselftest/arm64: Fix build failure with GCC-15
@ 2026-04-22 17:42 Leo Yan
  2026-04-22 17:50 ` Mark Brown
  2026-04-24 15:51 ` Catalin Marinas
  0 siblings, 2 replies; 6+ messages in thread
From: Leo Yan @ 2026-04-22 17:42 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Shuah Khan, Mark Brown,
	Thiago Jung Bauermann
  Cc: linux-arm-kernel, linux-kselftest, linux-kernel, Leo Yan

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.

Fixes: a505a52b4e29 ("kselftest/arm64: Add a GCS test program built with the system libc")
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
Changes in v2:
- Refined commit log (Mark Brown).
- Moving header to gcs-util.h (Mark Brown).
- Link to v1: https://lore.kernel.org/r/20260422-selftests_arm64_gcc15-v1-1-0d919ea5ac5f@arm.com
---
 tools/testing/selftests/arm64/gcs/gcs-util.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/arm64/gcs/gcs-util.h b/tools/testing/selftests/arm64/gcs/gcs-util.h
index c99a6b39ac147b4efbc9b5fbadb43daf4da2c85e..f583d4dbd0bfd964e08cf40b3951664c70bb031a 100644
--- a/tools/testing/selftests/arm64/gcs/gcs-util.h
+++ b/tools/testing/selftests/arm64/gcs/gcs-util.h
@@ -7,6 +7,7 @@
 #define GCS_UTIL_H
 
 #include <stdbool.h>
+#include <asm/ptrace.h>
 
 #ifndef __NR_map_shadow_stack
 #define __NR_map_shadow_stack 453

---
base-commit: 4ee64205ffaa587e8114d84a67ac721399ccb369
change-id: 20260421-selftests_arm64_gcc15-15f6f6d07dd8

Best regards,
-- 
Leo Yan <leo.yan@arm.com>



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

* Re: [PATCH v2] kselftest/arm64: Fix build failure with GCC-15
  2026-04-22 17:42 [PATCH v2] kselftest/arm64: Fix build failure with GCC-15 Leo Yan
@ 2026-04-22 17:50 ` Mark Brown
  2026-04-24 15:51 ` Catalin Marinas
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2026-04-22 17:50 UTC (permalink / raw)
  To: Leo Yan
  Cc: Catalin Marinas, Will Deacon, Shuah Khan, Thiago Jung Bauermann,
	linux-arm-kernel, linux-kselftest, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 585 bytes --]

On Wed, Apr 22, 2026 at 06:42:54PM +0100, Leo Yan wrote:

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

> +++ b/tools/testing/selftests/arm64/gcs/gcs-util.h
> @@ -7,6 +7,7 @@
>  #define GCS_UTIL_H
>  
>  #include <stdbool.h>
> +#include <asm/ptrace.h>
>  
>  #ifndef __NR_map_shadow_stack
>  #define __NR_map_shadow_stack 453

Reviewed-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v2] kselftest/arm64: Fix build failure with GCC-15
  2026-04-22 17:42 [PATCH v2] kselftest/arm64: Fix build failure with GCC-15 Leo Yan
  2026-04-22 17:50 ` Mark Brown
@ 2026-04-24 15:51 ` Catalin Marinas
  2026-04-24 16:07   ` Mark Brown
  1 sibling, 1 reply; 6+ messages in thread
From: Catalin Marinas @ 2026-04-24 15:51 UTC (permalink / raw)
  To: Leo Yan
  Cc: Will Deacon, Shuah Khan, Mark Brown, Thiago Jung Bauermann,
	linux-arm-kernel, linux-kselftest, linux-kernel

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


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

* Re: [PATCH v2] kselftest/arm64: Fix build failure with GCC-15
  2026-04-24 15:51 ` Catalin Marinas
@ 2026-04-24 16:07   ` Mark Brown
  2026-04-24 16:44     ` Catalin Marinas
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2026-04-24 16:07 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Leo Yan, Will Deacon, Shuah Khan, Thiago Jung Bauermann,
	linux-arm-kernel, linux-kselftest, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 683 bytes --]

On Fri, Apr 24, 2026 at 04:51:24PM +0100, Catalin Marinas wrote:
> On Wed, Apr 22, 2026 at 06:42:54PM +0100, Leo Yan wrote:

> > Building on Debian sid with GCC 15 fails:

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

I've not actually double checked that everything is wired up properly
but I believe these days this should actually pick up asm/ptrace.h from
the headers_install target so a current kernel copy.  We ought to be
able to remove the local definition of struct user_gcs I think, there's
still some weirdness with the NT_ definitions I can't remember but the
struct should be fine.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v2] kselftest/arm64: Fix build failure with GCC-15
  2026-04-24 16:07   ` Mark Brown
@ 2026-04-24 16:44     ` Catalin Marinas
  2026-04-24 17:09       ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Catalin Marinas @ 2026-04-24 16:44 UTC (permalink / raw)
  To: Mark Brown
  Cc: Leo Yan, Will Deacon, Shuah Khan, Thiago Jung Bauermann,
	linux-arm-kernel, linux-kselftest, linux-kernel

On Fri, Apr 24, 2026 at 05:07:42PM +0100, Mark Brown wrote:
> On Fri, Apr 24, 2026 at 04:51:24PM +0100, Catalin Marinas wrote:
> > On Wed, Apr 22, 2026 at 06:42:54PM +0100, Leo Yan wrote:
> 
> > > Building on Debian sid with GCC 15 fails:
> 
> > I think a better fix is to always define struct user_gcs and only
> > conditionally define NT_ARM_GCS (IOW, move the #endif higher).
> 
> I've not actually double checked that everything is wired up properly
> but I believe these days this should actually pick up asm/ptrace.h from
> the headers_install target so a current kernel copy.  We ought to be
> able to remove the local definition of struct user_gcs I think, there's
> still some weirdness with the NT_ definitions I can't remember but the
> struct should be fine.

OK, so it does look like it picks the kernel uapi/asm/ptrace.h. It
builds fine on Debian stable (no GCS anywhere) with including
asm/ptrace.h and removing struct user_gcs.

But I think we should include asm/ptrace.h in libc-gcs.h and not the
gcs-util.h header (for NT_ARM_GCS it's fine to keep in gcs-util.h).

-- 
Catalin


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

* Re: [PATCH v2] kselftest/arm64: Fix build failure with GCC-15
  2026-04-24 16:44     ` Catalin Marinas
@ 2026-04-24 17:09       ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2026-04-24 17:09 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Leo Yan, Will Deacon, Shuah Khan, Thiago Jung Bauermann,
	linux-arm-kernel, linux-kselftest, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 624 bytes --]

On Fri, Apr 24, 2026 at 05:44:16PM +0100, Catalin Marinas wrote:

> OK, so it does look like it picks the kernel uapi/asm/ptrace.h. It
> builds fine on Debian stable (no GCS anywhere) with including
> asm/ptrace.h and removing struct user_gcs.

> But I think we should include asm/ptrace.h in libc-gcs.h and not the
> gcs-util.h header (for NT_ARM_GCS it's fine to keep in gcs-util.h).

It's not glibc specific so it seems reasonable to keep it in gcs-util.h,
even though we don't currently have any nolibc stuff that uses ptrace.
That said this isn't particularly strongly held opinion so I don't
*really* mind either way.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2026-04-24 17:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-22 17:42 [PATCH v2] kselftest/arm64: Fix build failure with GCC-15 Leo Yan
2026-04-22 17:50 ` Mark Brown
2026-04-24 15:51 ` Catalin Marinas
2026-04-24 16:07   ` Mark Brown
2026-04-24 16:44     ` Catalin Marinas
2026-04-24 17:09       ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox