Skip to content

Build fails without -latomic with GCC 11.2.1 on Gentoo Linux RISC-V #8850

@IgnotaYun

Description

@IgnotaYun

master refuse to compile with GCC 11.2.1 on Gentoo Linux RISC-V, complains about missing __atomic_* symbols.

[ 89%] Building CXX object CMakeFiles/fish.dir/src/fish.cpp.o
[ 90%] Linking CXX executable fish
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.1/../../../../riscv64-unknown-linux-gnu/bin/ld: libfishlib.a(topic_monitor.cpp.o): in function `owning_lock<topic_monitor_t::data_t>::owning_lock()':
/home/gns/src/fish-shell/src/common.h:400: undefined reference to `__atomic_compare_exchange_1'
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.1/../../../../riscv64-unknown-linux-gnu/bin/ld: libfishlib.a(topic_monitor.cpp.o): in function `topic_monitor_t::post(topic_t)':
/home/gns/src/fish-shell/src/topic_monitor.cpp:134: undefined reference to `__atomic_compare_exchange_1'
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.1/../../../../riscv64-unknown-linux-gnu/bin/ld: libfishlib.a(topic_monitor.cpp.o): in function `std::mutex::lock()':
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.1/include/g++-v11/bits/std_mutex.h:104: undefined reference to `__atomic_compare_exchange_1'
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.1/../../../../riscv64-unknown-linux-gnu/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status 

RISC-V only has 4/4+8 byte atomic instruction for riscv32/riscv64 respectively, different from many other ISAs.

libpthread was merged into glibc 2.34, thus -pthread breaks, and no longer inherit linking of libatomic. Since GCC has yet implemented atomics inlining for RISC-V, plus the possibility of working with an old toolchain, a fix might be wanted.

Build log:
CMakeOutput.log
CMakeError.log

Update 4/4/2022: Clear some misunderstanding

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions