SUMMARY The code snippet for libatomic check compiles with no ld error on Sifive Unmatched, hence fails to detect the need to link against libatomic, resulting in "undefined reference to `__atomic_exchange_1'" STEPS TO REPRODUCE 1. compiles Krita normally following instructions in the document 2. or compile with emerge on Gentoo /usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld: libs/image/CMakeFiles/kritaimage.dir/tiles3/kis_tile_data_store.cc.o: in function `Leapfrog<ConcurrentMap<int, KisTileData*, DefaultKeyTraits<int>, DefaultValueTraits<KisTileData*> > >::TableMigration::run()': /var/tmp/portage/media-gfx/krita-4.4.8-r1/work/krita-4.4.8/libs/image/3rdparty/lock_free_map/leapfrog.h:475: undefined reference to `__atomic_exchange_1' /usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld: libs/image/CMakeFiles/kritaimage.dir/tiles3/kis_tiled_data_manager.cc.o: in function `Leapfrog<ConcurrentMap<unsigned int, KisTile*, DefaultKeyTraits<unsigned int>, DefaultValueTraits<KisTile*> > >::TableMigration::run()': /var/tmp/portage/media-gfx/krita-4.4.8-r1/work/krita-4.4.8/libs/image/3rdparty/lock_free_map/leapfrog.h:475: undefined reference to `__atomic_exchange_1' /usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld: libs/image/CMakeFiles/kritaimage.dir/tiles3/kis_memento_manager.cc.o: in function `Leapfrog<ConcurrentMap<unsigned int, KisMementoItem*, DefaultKeyTraits<unsigned int>, DefaultValueTraits<KisMementoItem*> > >::TableMigration::run()': /var/tmp/portage/media-gfx/krita-4.4.8-r1/work/krita-4.4.8/libs/image/3rdparty/lock_free_map/leapfrog.h:475: undefined reference to `__atomic_exchange_1' EXPECTED RESULT Krita compiles successfully SOFTWARE/OS VERSIONS Linux/KDE Plasma: (available in About System) KDE Plasma Version: 5.22.5 KDE Frameworks Version: 5.87.0 Qt Version: 5.15.2 ADDITIONAL INFORMATION HARDWARE: Sifive unmatched (riscv64 lp64d)
Created attachment 142490 [details] full compilatioin log compressed due to size limit, please use zcat to view
Please provide a patch: no Krita developer has access to hardware like this, so without a patch from someone who has, we cannot do anything.
So I take out the code piece for libatomic detection to test directly. It compiles with no error (which is meant to fail). unmatch2 /tmp # cat test.cpp #include <atomic> std::atomic<int> x; int main() { return std::atomic_is_lock_free(&x); } unmatch2 /tmp # gcc -Wall test.cpp test.cpp: In function ‘int main()’: test.cpp:4:10: warning: unused variable ‘i’ [-Wunused-variable] 4 | uint64_t i = x.load(std::memory_order_relaxed); | ^ test.cpp:5:6: warning: unused variable ‘b’ [-Wunused-variable] 5 | bool b = x.is_lock_free(); | ^ " I found this piece works from https://github.com/WebKit/WebKit/blob/87d88025bf5a3089e68b4466a12dd1cb2584d557/Source/cmake/WebKitCompilerFlags.cmake#L282 unmatch2 /tmp # cat test2.cpp #include <atomic> int main() { std::atomic<bool> y (false); std::atomic<uint64_t> x (0); bool expected = true; bool j = y.compare_exchange_weak(expected,false); x++; return 0; } unmatch2 /tmp # gcc test2.cpp /usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /tmp/.private/root/cc45pcng.o: in function `.L0 ': test2.cpp:(.text._ZNSt6atomicIbE21compare_exchange_weakERbbSt12memory_order[_ZNSt6atomicIbE21compare_exchange_weakERbbSt12memory_order]+0xb2): undefined reference to `__atomic_compare_exchange_1' collect2: error: ld returned 1 exit status My gcc version Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/riscv64-unknown-linux-gnu/11.2.0/lto-wrapper Target: riscv64-unknown-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-11.2.0/work/gcc-11.2.0/configure --host=riscv64-unknown-linux-gnu -- build=riscv64-unknown-linux-gnu --prefix=/usr --bindir=/usr/riscv64-unknown-linux-gnu/gcc-bin/11.2.0 --includedir=/u sr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/include --datadir=/usr/share/gcc-data/riscv64-unknown-linux-gnu/11.2.0 - -mandir=/usr/share/gcc-data/riscv64-unknown-linux-gnu/11.2.0/man --infodir=/usr/share/gcc-data/riscv64-unknown-linux -gnu/11.2.0/info --with-gxx-include-dir=/usr/lib/gcc/riscv64-unknown-linux-gnu/11.2.0/include/g++-v11 --with-python- dir=/share/gcc-data/riscv64-unknown-linux-gnu/11.2.0/python --enable-languages=c,c++,fortran --enable-obsolete --ena ble-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-except ions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 11.2.0 p1' --disable -esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --dis able-multilib --disable-fixed-point --with-abi=lp64d --enable-libgomp --disable-libssp --disable-libada --disable-sy stemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --withou t-zstd --enable-lto --withou t-isl --disable-libsanitizer --enable-default-pie --enable-default-ssp Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.2.0 (Gentoo 11.2.0 p1)
(In reply to Halla Rempt from comment #2) > Please provide a patch: no Krita developer has access to hardware like this, > so without a patch from someone who has, we cannot do anything. Hi, I think this is not limited to Sifive Unmatched. It is reproducible on any riscv hardware and even qemu riscv environment. I have also tested on Nezha D1 and on a qemu. They got the same result. Really appreciate if anyone in KDE team is willing to test on a riscv qemu vm or a riscv hardware. (In reply to alexfanqi@yahoo.com from comment #3) > unmatch2 /tmp # gcc -Wall test.cpp > test.cpp: In function ‘int main()’: > test.cpp:4:10: warning: unused variable ‘i’ [-Wunused-variable] > 4 | uint64_t i = x.load(std::memory_order_relaxed); > | ^ > test.cpp:5:6: warning: unused variable ‘b’ [-Wunused-variable] > 5 | bool b = x.is_lock_free(); > | ^ And my apology. please ignore this bit. I got it mixed with a report of this same issue to rocksdb. They basically use the same code piece for dectecting libatomic.
Created attachment 142491 [details] patch to fix libatomic check
Hi! I'm marking this bug as duplicate of 438072 since both report the same issue (incomplete check for libatomic). But since you've provided a patch, I'll make an alternative MR with it to have it merged for 5.0. *** This bug has been marked as a duplicate of bug 438072 ***
*** This bug has been marked as a duplicate of bug 430872 ***
Git commit f963f4f42b66715405c9bf087c630df8725332a2 by Halla Rempt, on behalf of L. E. Segovia. Committed on 19/10/2021 at 07:45. Pushed by rempt into branch 'master'. Upgrade CheckAtomic module to a copy of ECM 5.75 I am making this commit since !498 seems to not have progressed for quite a few months. Related: bug 430872 Closes !498 M +61 -59 cmake/modules/CheckAtomic.cmake https://invent.kde.org/graphics/krita/commit/f963f4f42b66715405c9bf087c630df8725332a2
Git commit 8e7ccd3cd7601ac4c27696eafd8cd1bb8a40296c by L. E. Segovia. Committed on 22/10/2021 at 21:23. Pushed by lsegovia into branch 'master'. Fix compiler check on CheckAtomic LLVM_COMPILER_IS_GCC_COMPATIBLE is set by another module in LLVM, which neither we nor ECM copy on their source. Related: bug 430872 M +14 -4 cmake/modules/CheckAtomic.cmake https://invent.kde.org/graphics/krita/commit/8e7ccd3cd7601ac4c27696eafd8cd1bb8a40296c
Git commit 410ed417d5ac317f85eefc0f3b5c437b53537d07 by L. E. Segovia. Committed on 22/10/2021 at 21:56. Pushed by lsegovia into branch 'krita/5.0'. Upgrade CheckAtomic module to a copy of ECM 5.75 I am making this commit since !498 seems to not have progressed for quite a few months. Related: bug 430872 Closes !498 (cherry picked from commit f963f4f42b66715405c9bf087c630df8725332a2) M +61 -59 cmake/modules/CheckAtomic.cmake https://invent.kde.org/graphics/krita/commit/410ed417d5ac317f85eefc0f3b5c437b53537d07
Git commit daa53222c830c9b7a5b6c9e8efb322233d7cbc67 by L. E. Segovia. Committed on 22/10/2021 at 21:56. Pushed by lsegovia into branch 'krita/5.0'. Fix compiler check on CheckAtomic LLVM_COMPILER_IS_GCC_COMPATIBLE is set by another module in LLVM, which neither we nor ECM copy on their source. Related: bug 430872 (cherry picked from commit 8e7ccd3cd7601ac4c27696eafd8cd1bb8a40296c) M +14 -4 cmake/modules/CheckAtomic.cmake https://invent.kde.org/graphics/krita/commit/daa53222c830c9b7a5b6c9e8efb322233d7cbc67