Since the merge of #19937, riscv builds have been failing, due to a link issue with std::atomic_exchange in bitcoin-util:
CXXLD bitcoin-util
bitcoin_util-bitcoin-util.o: In function `grind_task':
/home/ubuntu/build/bitcoin/distsrc-riscv64-linux-gnu/src/bitcoin-util.cpp:98: undefined reference to `__atomic_exchange_1'
collect2: error: ld returned 1 exit status
We have a macro that tries to determine when -latomic is required, however it doesn't quite work well enough, as it's currently determining it isn't needed:
./autogen.sh
./configure --prefix=/home/ubuntu/bitcoin/depends/riscv64-linux-gnu
...
checking whether std::atomic can be used without link library... yes
This PR adds a call to std::atomic_exchange to the macro, which will get us properly linked against -latomic on riscv:
checking whether std::atomic can be used without link library... no
checking whether std::atomic needs -latomic... yes
Also adds an <atomic> include to bitcoin-util.cpp.