Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 790689 - dev-qt/qtdeclarative-5.15.2: missing "-latomic" (undefined reference to `__atomic_fetch_or_2')
Summary: dev-qt/qtdeclarative-5.15.2: missing "-latomic" (undefined reference to `__at...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: riscv Linux
: Normal normal (vote)
Assignee: Qt Bug Alias
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: libatomic-linking
  Show dependency tree
 
Reported: 2021-05-17 13:21 UTC by Yixun Lan
Modified: 2021-08-11 08:03 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
full build log (build.log.xz,9.49 KB, application/x-xz)
2021-05-17 13:22 UTC, Yixun Lan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yixun Lan archtester gentoo-dev 2021-05-17 13:21:31 UTC
this happens while building on ARCH=rsicv, both occur with gcc-10.2.0, 11.1.0

/usr/lib/gcc/riscv64-unknown-linux-gnu/11.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: .obj/qv4typedarray.o: in function `.L932':
qv4typedarray.cpp:(.text._Z8atomicOrIsEyPcN3QV45ValueE[_Z8atomicOrIsEyPcN3QV45ValueE]+0xa2): undefined reference to `__atomic_fetch_or_2'
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: .obj/qv4typedarray.o: in function `.L1156':
qv4typedarray.cpp:(.text._Z21atomicCompareExchangeIsEyPcN3QV45ValueES2_[_Z21atomicCompareExchangeIsEyPcN3QV45ValueES2_]+0xe8): undefined reference to `__atomic_compare_exchange_2'
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: .obj/qv4typedarray.o: in function `.L1373':
qv4typedarray.cpp:(.text._Z21atomicCompareExchangeItEyPcN3QV45ValueES2_[_Z21atomicCompareExchangeItEyPcN3QV45ValueES2_]+0xe4): undefined reference to `__atomic_compare_exchange_2'
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: .obj/qv4typedarray.o: in function `.L1412':
qv4typedarray.cpp:(.text._Z21atomicCompareExchangeIaEyPcN3QV45ValueES2_[_Z21atomicCompareExchangeIaEyPcN3QV45ValueES2_]+0xe8): undefined reference to `__atomic_compare_exchange_1'
/usr/lib/gcc/riscv64-unknown-linux-gnu/11.1.0/../../../../riscv64-unknown-linux-gnu/bin/ld: .obj/qv4typedarray.o: in function `.L1451':
qv4typedarray.cpp:(.text._Z21atomicCompareExchangeIhEyPcN3QV45ValueES2_[_Z21atomicCompareExchangeIhEyPcN3QV45ValueES2_]+0xe4): undefined reference to `__atomic_compare_exchange_1'
collect2: error: ld returned 1 exit status


Reproducible: Always
Comment 1 Yixun Lan archtester gentoo-dev 2021-05-17 13:22:34 UTC
Created attachment 709434 [details]
full build log
Comment 2 Alex Fan archtester 2021-06-26 02:28:05 UTC
The same bug happened to me as well on qemu riscv64. 
I modified the source code in the portage tmp working folder as a quick hack. 
In file src/qml/Makefile, add '-latomic' to "LIBS=..."
It passes the compilation and seems to work fine.
Comment 3 Yixun Lan archtester gentoo-dev 2021-06-27 09:29:16 UTC
probably we could fix it as similar as this commit?
 
https://github.com/MariaDB/server/pull/978/commits/27b380ed8ee8457597117ed3fae155b7ac94d60a
Comment 4 Yixun Lan archtester gentoo-dev 2021-06-28 22:52:29 UTC
this is a simple patch that works for me..

--- a/src/qml/qml.pro
+++ b/src/qml/qml.pro
@@ -19,6 +19,7 @@ solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
 
 # Ensure this gcc optimization is switched off for mips platforms to avoid trouble with JIT.
 gcc:isEqual(QT_ARCH, "mips"): QMAKE_CXXFLAGS += -fno-reorder-blocks
+gcc:isEqual(QT_ARCH, "riscv64"): LIBS += -latomic
 
 DEFINES += QT_NO_FOREACH
Comment 5 Alex Fan archtester 2021-07-01 03:46:29 UTC
This bug has been around in Qt 5.2 since May of last year. Check out <https://bugreports.qt.io/browse/QTBUG-84580>. 

If anyone can confirm this bug in Qt6, please report it to upstream as well. I will also try testing Qt 6.
Comment 6 Davide Pesavento gentoo-dev 2021-07-17 20:06:53 UTC
(In reply to Yixun Lan from comment #4)
> this is a simple patch that works for me..
> 
> --- a/src/qml/qml.pro
> +++ b/src/qml/qml.pro
> @@ -19,6 +19,7 @@ solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2
>  
>  # Ensure this gcc optimization is switched off for mips platforms to avoid
> trouble with JIT.
>  gcc:isEqual(QT_ARCH, "mips"): QMAKE_CXXFLAGS += -fno-reorder-blocks
> +gcc:isEqual(QT_ARCH, "riscv64"): LIBS += -latomic
>  
>  DEFINES += QT_NO_FOREACH

I don't think this is the right fix, it would mean every consumer of the QAtomic stuff (both inside and outside of Qt) has to be patched to link with -latomic. A likely better fix is to have qtcore detect the need for -latomic at configure time and, if needed, link to it.

That being said, I think we can merge the proposed workaround as it doesn't affect other arches and a better fix is unlikely to come any time soon.
Comment 7 Larry the Git Cow gentoo-dev 2021-07-17 22:45:57 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=980dc7e8d6fd082c77650dc05051af0f7e1b8b3a

commit 980dc7e8d6fd082c77650dc05051af0f7e1b8b3a
Author:     Yixun Lan <dlan@gentoo.org>
AuthorDate: 2021-07-17 15:18:56 +0000
Commit:     Yixun Lan <dlan@gentoo.org>
CommitDate: 2021-07-17 22:45:21 +0000

    dev-qt/qtdeclarative: riscv: fix missing atomic library
    
    this will workaroud the error when build in ARCH=riscv,
    tested with gcc-11
    
    A likely better fix is to have qtcore detect the need for -latomic
    at configure time and, if needed, link to it
    
    Bug: https://bugs.gentoo.org/790689
    Closes: https://github.com/gentoo/gentoo/pull/21689
    Package-Manager: Portage-3.0.19, Repoman-3.0.3
    Signed-off-by: Yixun Lan <dlan@gentoo.org>

 .../files/qtdeclarative-5.15.2-riscv-atomic.patch            | 12 ++++++++++++
 dev-qt/qtdeclarative/qtdeclarative-5.15.2.ebuild             |  1 +
 2 files changed, 13 insertions(+)
Comment 8 Larry the Git Cow gentoo-dev 2021-08-11 08:03:48 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/qt.git/commit/?id=d841a158e7300cdacdf53c8e79c1fe368d36f7d5

commit d841a158e7300cdacdf53c8e79c1fe368d36f7d5
Author:     Yixun Lan <dlan@gentoo.org>
AuthorDate: 2021-07-17 15:18:56 +0000
Commit:     Andreas Sturmlechner <asturm@gentoo.org>
CommitDate: 2021-08-10 18:33:01 +0000

    dev-qt/qtdeclarative: riscv: fix missing atomic library
    
    this will workaroud the error when build in ARCH=riscv,
    tested with gcc-11
    
    A likely better fix is to have qtcore detect the need for -latomic
    at configure time and, if needed, link to it
    
    Bug: https://bugs.gentoo.org/790689
    Package-Manager: Portage-3.0.19, Repoman-3.0.3
    Signed-off-by: Yixun Lan <dlan@gentoo.org>
    Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>

 .../files/qtdeclarative-5.15.2-riscv-atomic.patch            | 12 ++++++++++++
 dev-qt/qtdeclarative/qtdeclarative-5.15.9999.ebuild          |  1 +
 2 files changed, 13 insertions(+)