1From e9d1f80dffb4e29e44fc0b0627704af15cdd281a Mon Sep 17 00:00:00 2001
2From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3Date: Sun, 13 Mar 2022 12:05:04 +0100
4Subject: [PATCH] src/corelib/configure.json: fix atomicfptr detection
5
6Fix atomicfptr detection on sparc v8 by linking with libatomic if needed
7to avoid the following build failure:
8
9/sysroot -std=gnu++11 -w -fPIC  -I. -I/home/peko/autobuild/instance-0/output-1/build/qt5base-d16bf02a11953dcac01dca73e6f3778f293adefe/mkspecs/devices/linux-buildroot-g++ -o main.o main.cpp
10> /home/peko/autobuild/instance-0/output-1/host/bin/sparc-linux-g++ --sysroot=/home/peko/autobuild/instance-0/output-1/host/sparc-buildroot-linux-uclibc/sysroot --sysroot=/home/peko/autobuild/instance-0/output-1/host/sparc-buildroot-linux-uclibc/sysroot -Wl,-O1 -o atomicfptr main.o   -lexecinfo  -lrt -lpthread -ldl
11> /home/peko/autobuild/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/10.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: main.o: in function `test(std::atomic<void (*)(int)> volatile&)':
12> main.cpp:(.text+0x40): undefined reference to `__atomic_compare_exchange_4'
13> collect2: error: ld returned 1 exit status
14> make[1]: *** [Makefile:69: atomicfptr] Error 1
15
16[...]
17
18ERROR: detected a std::atomic implementation that fails for function pointers.
19Please apply the patch corresponding to your Standard Library vendor, found in
20  qtbase/config.tests/atomicfptr
21
22Fixes:
23 - http://autobuild.buildroot.org/results/5a20e984a5536165056b3fbd93b8712e8ddbeed4
24
25Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
26[Upstream status:
27https://invent.kde.org/qt/qt/qtbase/-/merge_requests/138]
28---
29 src/corelib/configure.json | 3 ++-
30 1 file changed, 2 insertions(+), 1 deletion(-)
31
32diff --git a/src/corelib/configure.json b/src/corelib/configure.json
33index 9b5d19d41b..ac88f5856c 100644
34--- a/src/corelib/configure.json
35+++ b/src/corelib/configure.json
36@@ -309,7 +309,8 @@
37                     "test(fptr);"
38                 ],
39                 "qmake": "CONFIG += c++11"
40-            }
41+            },
42+            "use": "libatomic"
43         },
44         "clock-monotonic": {
45             "label": "POSIX monotonic clock",
46--
472.34.1
48
49