Linking failure on RISC-V with GCC 11.2.1
envgap__arvidn__libtorrent-6794
01 / FAILURE SIGNATURE
As reported upstream
so.2.0.5: undefined reference to `__atomic_exchange_1'
Not a benchmark task.
- In a clean container the reported failure did not reproduce, or the known fix did not make the project run.
02 / ENVIRONMENT RECIPE
- Base commit
9c04d24504d5e447d95e14c9f9fc6417079dec6d- Manifest
CMakeLists.txt- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
arvidn/libtorrent #6794 · read the original issue
libtorrent version (or branch): `2.0.5` Platform/Architecture: RISC-V, Gentoo Linux, with `lp64d systemd` profile Compiler and compiler version: `gcc (Gentoo 11.2.1_p20220115 p4) 11.2.1 20220115` Encountered the problem while trying to compile the qBittorrent 4.4.2 ebuild with latest portage tree. `libtorrent-rasterbar` was built successfully, but during linking of qBittorrent it would fail due to missing `__atomic_*` symbol from `libtorrent`. ``` /usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /usr/lib64/libtorrent-rasterbar. so.2.0.5: undefined reference to `__atomic_exchange_1' collect2: error: ld returned 1 exit status distcc[2276441] ERROR: compile (null) on localhost failed ninja: build stopped: subcommand failed. ``` AFAIK, this is because CMake script fails to detect missing subword atomic, as RISC-V doesn't have 1/2 byte atomic instruction. - GCC should provide subword atomic inlining IMO, but currently they don't. - This was bypassed by prefer `pthread`, hints linking to `latomic` previously (#6722). However, after glibc 2.34, `-pthread` is nolonger needed to use `pthread` libraries, hence no more linking to `latomic`. Since replying on `-pthread` for atomic is sementically incorrect, plus we already have a detection mechanism here, a possible fix could be enhance the detection. Build log: [libtorrent-rasterbar-2.0.5-r1.log](https://github.com/arvidn/libtorrent/files/8411284/libtorrent-rasterbar-2.0.5-r1_20220403-153624.log) [qbittorrent-4.4.2.log](https://github.com/arvidn/libtorrent/files/8411287/qbittorrent-4.4.2_20220403-161029.log)
04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]