On Sat, Sep 26, 2026 at 11:02:57AM +0000, Torbjörn Svensson via Sourceware 
Forge wrote:
> From: Torbjörn SVENSSON <[email protected]>
> 
> gcc/testsuite/ChangeLog:
> 
>       * gcc.dg/pr127492.c: Add require effective target
>       sync_long_long_runtime.
> 
> Signed-off-by: Torbjörn SVENSSON <[email protected]>
> ---
> For arm-none-eabi, all my Cortex-M targets fail with:
> 
> pr127492.c:(.text.startup+0x14): undefined reference to `__atomic_fetch_add_8'
> /build/r17-4665-g36aa829e54652e/arm-none-eabi/bin/ld: (__atomic_fetch_add_8): 
> Unknown destination type (ARM/Thumb) in /tmp/ccB4vlG3.o
> pr127492.c:(.text.startup+0x14): dangerous relocation: unsupported relocation
> 
> Ok for trunk?

No, this is wrong.
The test uses __int128 atomics on int128 targets and long long atomics on other
targets, so whether sync_long_long_runtime is satisfied is completely
irrelevant on most of the 64-bit targets.
But more importantly, the test wants to test at runtime the codepath where
we emit the libatomic function call, so we do want to test it on targets
where it isn't supported in hw.

So, either we should go with something like:
--- a/gcc/testsuite/gcc.dg/pr127492.c   2026-09-22 14:58:11.232624179 +0200
+++ b/gcc/testsuite/gcc.dg/pr127492.c   2026-09-29 08:51:56.240821492 +0200
@@ -1,5 +1,5 @@
 /* PR middle-end/127492 */
-/* { dg-do run } */
+/* { dg-do run { target { { { int128 && sync_int_128_runtime } || { { ! int128 
} && sync_long_long_runtime } } || libatomic_available } } } */
 /* { dg-options "-O2" } */
 /* { dg-additional-options "-latomic" { target libatomic_available } } */
 
but that somehow doesn't really work correctly, don't know what I'm doing
wrong.  In particular, the test PASSes for me on x86_64-linux and i686-linux
this way, but when I take out the " || libatomic_available" part, it is
UNSUPPORTED instead of the expected UNSUPPORTED for -m64 (only loongarch64
has that effective target), but it should be really PASS for -m32 (as
sync_long_long_runtime should be true).  But somehow it isn't even checked.

Or just /* { dg-do run { target libatomic_available } } */ and add
-latomic to dg-options and drop dg-additional-options.

Or split the test into two, one which only uses __int128 and is
{ int128 && { sync_int_128_runtime || libatomic_available } }
if that works, and one that is using long long always and is
{ sync_long_long_runtime || libatomic_available }.

        Jakub

Reply via email to