On 03/08/2026 12:56, Torbjorn SVENSSON wrote:
> 
> 
> On 2026-08-03 13:54, Jakub Jelinek wrote:
>> On Mon, Aug 03, 2026 at 01:50:18PM +0200, Torbjorn SVENSSON wrote:
>>> This change introduces new failures for arm-none-eabi using 
>>> thumb/arch=armv6s-m/cpu=cortex-m0/float-abi=soft/fpu=auto.
>>>
>>> Testing torture/bitint-100.c,   -O0
>>> doing compile
>>> Executing on host: /build/install-native/bin/arm-none-eabi-gcc  
>>> /build/gcc_src/gcc/testsuite/gcc.dg/torture/bitint-100.c  -mthumb 
>>> -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -mfpu=auto   -dumpbase "" 
>>> -fdiagnostics-plain-output    -O0  -std=c23 -pedantic-errors      
>>> --specs=rdimon.specs -Wl,--start-group -lc -lm -Wl,--end-group 
>>> --specs=nosys.specs -Wl,--allow-multiple-definition 
>>> -Wl,-u,_isatty,-u,_fstat  -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main 
>>> -Wl,-wrap,abort -Wl,gcc_tg.o -lm -T qemu.ld -o ./bitint-100.exe    (timeout 
>>> = 800)
>>> spawn -ignore SIGHUP /build/install-native/bin/arm-none-eabi-gcc 
>>> /build/gcc_src/gcc/testsuite/gcc.dg/torture/bitint-100.c -mthumb 
>>> -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -mfpu=auto -dumpbase  
>>> -fdiagnostics-plain-output -O0 -std=c23 -pedantic-errors 
>>> --specs=rdimon.specs -Wl,--start-group -lc -lm -Wl,--end-group 
>>> --specs=nosys.specs -Wl,--allow-multiple-definition 
>>> -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main 
>>> -Wl,-wrap,abort -Wl,gcc_tg.o -lm -T qemu.ld -o ./bitint-100.exe
>>> pid is 1478576 -1478576
>>> /build/install-native/arm-none-eabi/bin/ld: /tmp/ccgSaSgH.o: in function 
>>> `f1':
>>> bitint-100.c:(.text+0x5a): undefined reference to 
>>> `__atomic_compare_exchange_4'
>>> /build/install-native/arm-none-eabi/bin/ld: (__atomic_compare_exchange_4): 
>>> Unknown destination type (ARM/Thumb) in /tmp/ccgSaSgH.o
>>> bitint-100.c:(.text+0x5a): dangerous relocation: unsupported relocation
>>> /build/install-native/arm-none-eabi/bin/ld: /tmp/ccgSaSgH.o: in function 
>>> `f2':
>>> bitint-100.c:(.text+0xa4): undefined reference to 
>>> `__atomic_compare_exchange_4'
>>> /build/install-native/arm-none-eabi/bin/ld: (__atomic_compare_exchange_4): 
>>> Unknown destination type (ARM/Thumb) in /tmp/ccgSaSgH.o
>>> bitint-100.c:(.text+0xa4): dangerous relocation: unsupported relocation
>>> ...
>>> collect2: error: ld returned 1 exit status
>>>   status 1
>>> compiler exited with status 1
>>> FAIL: gcc.dg/torture/bitint-100.c   -O0  (test for excess errors)
>>>
>>> Same failure exist on both trunk and releases/gcc-16.
>>
>> I thought gcc has been changed to add -latomic_asneeded by default.
>> Or is this because the linker doesn't support it in this configuration?
> To my knowledge, there is no atomic support for armv6s-m, but I can be wrong.
> 

armv6-m has a DMB sync instruction, but that's all.  On earlier systems the 
only support we have for atomics is via __sync_synchronize.  That will always 
be a lib-call if we don't know for sure that we have the DMB sync.  If at link 
time, we can determine that the core is single-threaded only, then the call 
will become a no-op, otherwise (eg we end up linking for a later architecture) 
we will use the atomic primitive appropriate for the final architecture.  This 
is all handled in libgcc through the code in arm/lib1funcs.asm.

R.

> Kind regards,
> Torbjörn

Reply via email to