https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122078
Sebastian Huber <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sebastian.huber@embedded-br | |ains.de --- Comment #10 from Sebastian Huber <[email protected]> --- The defect also shows up on riscv-rtems for a target without the A extension. GCC 16.2.1 for riscv-rtems7 with -march=rv64imc -mabi=lp64 -mcmodel=medany -mstrict-align emits a tail call to __atomic_test_and_set for atomic_flag_test_and_set(). The link of any C++ program which uses std::thread then fails, although the RTEMS driver spec links -latomic: std_thread.h:175: undefined reference to `__atomic_test_and_set' Test case: #include <stdatomic.h> #include <stdbool.h> bool tas(atomic_flag *f) { return atomic_flag_test_and_set(f); } riscv-rtems7-gcc -O2 -S -march=rv64imc -mabi=lp64 test.c tas: li a1,5 tail __atomic_test_and_set The same target calls __atomic_exchange_1 and __atomic_fetch_add_1 for the corresponding operations on atomic_uint_least8_t. libatomic provides these. It provides __atomic_test_and_set_1 as well, but not __atomic_test_and_set. I sent a patch with the same approach as attachment 62710 in July 2025. It also got no review: https://gcc.gnu.org/pipermail/gcc-patches/2025-July/689154.html https://gcc.gnu.org/pipermail/gcc-patches/2025-August/692551.html https://gcc.gnu.org/pipermail/gcc-patches/2025-August/693076.html The discussion on the gcc list: https://gcc.gnu.org/pipermail/gcc/2025-July/246261.html
