diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2021-01-18 18:33:19 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2021-01-18 18:33:24 +0100 |
commit | c763cacb883c77f7b8baf1b913a73943cf7c2180 (patch) | |
tree | 743af9cedc47cafe002d37b52225040288b4087a /src/bitcoin-util.cpp | |
parent | 7acda55c4fa611481979a41dfd5ca016bb535409 (diff) | |
parent | 54ce4fac80689621dcbcc76169b2b00b179ee743 (diff) |
Merge #20938: build: fix linking against -latomic when building for riscv
54ce4fac80689621dcbcc76169b2b00b179ee743 build: improve macro for testing -latomic requirement (fanquake)
2c010b9c56f069efad2b2c10bffaef4ed059736e add std::atomic include to bitcoin-util.cpp (fanquake)
Pull request description:
Since the merge of #19937, riscv builds have been failing, due to a link issue with [`std::atomic_exchange`](https://en.cppreference.com/w/cpp/atomic/atomic_exchange) in `bitcoin-util`:
```bash
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](https://github.com/bitcoin/bitcoin/blob/master/build-aux/m4/l_atomic.m4) 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:
```bash
./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:
```bash
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`.
ACKs for top commit:
laanwj:
Tested ACK 54ce4fac80689621dcbcc76169b2b00b179ee743
Tree-SHA512: 963c875097ee96b131163ae8109bcf8fecf4451d20faa2f3d223f9938ea3d8d1ed5604e12ad82c2b4b1c605fd293a9b6b08fefc00dd3e68d09c49e95029c6f50
Diffstat (limited to 'src/bitcoin-util.cpp')
-rw-r--r-- | src/bitcoin-util.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/bitcoin-util.cpp b/src/bitcoin-util.cpp index 30b8098716..af07b28d3d 100644 --- a/src/bitcoin-util.cpp +++ b/src/bitcoin-util.cpp @@ -25,6 +25,7 @@ #include <util/system.h> #include <util/translation.h> +#include <atomic> #include <functional> #include <memory> #include <stdio.h> |