__atomic_test_and_set() and mips o32 - help wanted
matthew green <[email protected]> Sun, 16 Nov 2025 20:10:37 +1100
| Newsgroups | gmane.os.netbsd.ports.mips.devel,gmane.os.netbsd.devel.toolchain |
|---|---|
| Message-ID | <[email protected]> |
hi folks. one of the GCC 14 issues is that for mips o32, libstdc++ tries to use a newer-ish builtin called __atomic_test_and_set(), that ends up emitting a call to a library function on o32, which leads to a link failure in gdb (and more). this library function is defined as: bool __atomic_test_and_set(bool *ptr, int memorder); where "memorder" is from <stdatomic.h> and is eg, "memory_order_relaxed", or "memory_order_consume", or a few other options. using -abi=n32 or -abi=64 generates a bunch of code using ll/sc, and some ugly crap to only operate on one byte. the n32 one is: https://www.netbsd.org/~mrg/mips-n32-atomic_test_and_set.s the libstdc++ direct calls to __atomic_test_and_set() are in: external/gpl3/gcc/dist/libstdc++-v3/include/bits/atomic_base.h there is a _GLIBCXX_ATOMIC_BUILTINS define that should be able to implement these differently if possible.. the same problem exists on sh3, but there's a workaround i just seem to have tested (sh3 and sh4 cpus support tas.b instruction, but gcc wants "-mtas" to enable it.) i'm not sure what the right thing to do here is. it's not clear to me that the actual old 32-bit hardware can do this at all, but there are now explicit calls to this builtin. GCC configury tries to find and notice it's missing, but libstdc++ still has a couple of calls to it directly in it's "test_and_set()". anyone have a good idea? .mrg.