NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/57312: Missing atomic symbols generated by gcc



>Number:         57312
>Category:       lib
>Synopsis:       Missing atomic symbols generated by gcc
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 30 15:20:00 +0000 2023
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The NetBSD Foundation_explicit(memory_order_acq_rel)
>Environment:
brittle when cooked
>Description:
libc is missing many of the __atomic_* symbols that gcc generates references to for certain out-of-line cases of the C11 stdatomic.h API.

Cases where symbols are missing:

- On architectures that don't natively have CAS, like sparc, hppa, and early mips.
- For objects of unnaturally large sizes, for which atomic_is_lock_free is false and locking is required.
- When the -fno-inline-atomics flag is passed.

We probably need to define all the symbols listed here:
https://gcc.gnu.org/wiki/Atomic/GCCMM?action=AttachFile&do=view&target=libatomic.c

I added __atomic_is_lock_free for a handful of architectures where its absence immediately broke the OpenSSL build, but there are lots more.
>How-To-Repeat:
% cat >foo.c <<EOF
#include <stdatomic.h>

_Atomic struct { int x[32]; } s;

int
main(void)
{
    return atomic_load(&s).x[0];
}
EOF
% gcc -c -fno-inline-atomics foo.c
/usr/bin/ld: /tmp/ccfArqpG.o: in function `main':
foo.c:(.text+0x24): undefined reference to `__atomic_load'
collect2: error: ld returned 1 exit status

>Fix:
Yes, please!



Home | Main Index | Thread Index | Old Index