From dd4b64ebecc5ca60615773dc72b530aec799c146 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Sat, 14 May 2022 17:42:12 +0300 Subject: [PATCH] Backport two upstream patches to fix libatomic detection. --- debian/changelog | 2 + debian/patches/series | 4 + ...Explicitly-check-for-atomic-addition.patch | 82 +++++++++++++++++++ ...tream_Hardcode-atomic_LIB-as-latomic.patch | 35 ++++++++ 4 files changed, 123 insertions(+) create mode 100644 debian/patches/upstream_Explicitly-check-for-atomic-addition.patch create mode 100644 debian/patches/upstream_Hardcode-atomic_LIB-as-latomic.patch diff --git a/debian/changelog b/debian/changelog index 56c0823..421cfd8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,7 @@ qt6-base (6.2.4+dfsg-7) UNRELEASED; urgency=medium + [ Dmitry Shachnev ] + * Backport two upstream patches to fix libatomic detection. -- Debian Qt/KDE Maintainers Sat, 14 May 2022 17:41:32 +0300 diff --git a/debian/patches/series b/debian/patches/series index 347b333..042e0e2 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,6 +1,10 @@ # fixed in 6.3 upstream_QStorageInfo-limit-Linux-only-code-with-Q_OS_LINUX.patch +# fixed in 6.3.1 +upstream_Explicitly-check-for-atomic-addition.patch +upstream_Hardcode-atomic_LIB-as-latomic.patch + # fixed in 6.4 upstream_CMake-add-support-for-GNU-Hurd.patch upstream_QProcess-Unix-fallback-on-_POSIX_PIPE_BUF-w-missing-.patch diff --git a/debian/patches/upstream_Explicitly-check-for-atomic-addition.patch b/debian/patches/upstream_Explicitly-check-for-atomic-addition.patch new file mode 100644 index 0000000..da9c3a6 --- /dev/null +++ b/debian/patches/upstream_Explicitly-check-for-atomic-addition.patch @@ -0,0 +1,82 @@ +From 4088b27b9397fa9877bf60b8e707bba5dc51e9cb Mon Sep 17 00:00:00 2001 +From: Moody Liu +Date: Tue, 12 Apr 2022 10:40:00 +0100 +Subject: [PATCH] Explicitly check for atomic addition and relaxed load + operation support + +...and properly find and link against `libatomic` using find_library. +This fixes the qtdeclarative build on the RISC-V platform. + +Initial-patch-by: Sprite +Pick-to: 6.2 +Pick-to: 6.3 +Task-number: QTBUG-99234 +Change-Id: I2b5e4812886ce45cb02bed3106ce8c519b294cbe +Reviewed-by: Thiago Macieira +Reviewed-by: Jörg Bornemann +--- + cmake/FindWrapAtomic.cmake | 34 +++++++++++++++++++--------------- + 1 file changed, 19 insertions(+), 15 deletions(-) + +diff --git a/cmake/FindWrapAtomic.cmake b/cmake/FindWrapAtomic.cmake +index c2582bdd6b..3ea72bb188 100644 +--- a/cmake/FindWrapAtomic.cmake ++++ b/cmake/FindWrapAtomic.cmake +@@ -10,35 +10,39 @@ include(CheckCXXSourceCompiles) + set (atomic_test_sources "#include + #include + +-void test(volatile std::atomic &a) +-{ +- std::int64_t v = a.load(std::memory_order_acquire); +- while (!a.compare_exchange_strong(v, v + 1, +- std::memory_order_acq_rel, +- std::memory_order_acquire)) { +- v = a.exchange(v - 1); +- } +- a.store(v + 1, std::memory_order_release); +-} +- + int main(int, char **) + { +- void *ptr = (void*)0xffffffc0; // any random pointer +- test(*reinterpret_cast *>(ptr)); ++ volatile std::atomic size_1; ++ volatile std::atomic size_2; ++ volatile std::atomic size_4; ++ volatile std::atomic size_8; ++ ++ ++size_1; ++ ++size_2; ++ ++size_4; ++ ++size_8; ++ ++ (void)size_1.load(std::memory_order_relaxed); ++ (void)size_2.load(std::memory_order_relaxed); ++ (void)size_4.load(std::memory_order_relaxed); ++ (void)size_8.load(std::memory_order_relaxed); ++ + return 0; + }") + + check_cxx_source_compiles("${atomic_test_sources}" HAVE_STDATOMIC) + if(NOT HAVE_STDATOMIC) + set(_req_libraries "${CMAKE_REQUIRED_LIBRARIES}") +- set(CMAKE_REQUIRED_LIBRARIES "atomic") ++ find_library(atomic_LIB atomic REQUIRED) ++ set(CMAKE_REQUIRED_LIBRARIES ${atomic_LIB}) + check_cxx_source_compiles("${atomic_test_sources}" HAVE_STDATOMIC_WITH_LIB) + set(CMAKE_REQUIRED_LIBRARIES "${_req_libraries}") + endif() + + add_library(WrapAtomic::WrapAtomic INTERFACE IMPORTED) + if(HAVE_STDATOMIC_WITH_LIB) +- target_link_libraries(WrapAtomic::WrapAtomic INTERFACE atomic) ++ # atomic_LIB is already found above. ++ target_link_libraries(WrapAtomic::WrapAtomic INTERFACE ${atomic_LIB}) + endif() + + set(WrapAtomic_FOUND 1) +-- +2.35.1 + diff --git a/debian/patches/upstream_Hardcode-atomic_LIB-as-latomic.patch b/debian/patches/upstream_Hardcode-atomic_LIB-as-latomic.patch new file mode 100644 index 0000000..034b8ca --- /dev/null +++ b/debian/patches/upstream_Hardcode-atomic_LIB-as-latomic.patch @@ -0,0 +1,35 @@ +From e2a8b0adbd099cfda84e931f6a24f34e80b12fd7 Mon Sep 17 00:00:00 2001 +From: Dmitry Shachnev +Date: Sat, 7 May 2022 20:51:25 +0300 +Subject: [PATCH] Hardcode atomic_LIB as -latomic + +find_library does not always work because libatomic.so may be in a path +like /usr/lib/gcc/x86_64-linux-gnu/11/libatomic.so, which CMake does not +consider by default. + +Pick-to: 6.3 +Change-Id: I73a657c470efa4f84f8629bd531edfcac3b3a352 +Reviewed-by: Alexey Edelev +Reviewed-by: Thiago Macieira +Reviewed-by: Qt CI Bot +Reviewed-by: Jörg Bornemann +--- + cmake/FindWrapAtomic.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cmake/FindWrapAtomic.cmake b/cmake/FindWrapAtomic.cmake +index 3ea72bb188..006be0ed8f 100644 +--- a/cmake/FindWrapAtomic.cmake ++++ b/cmake/FindWrapAtomic.cmake +@@ -33,7 +33,7 @@ int main(int, char **) + check_cxx_source_compiles("${atomic_test_sources}" HAVE_STDATOMIC) + if(NOT HAVE_STDATOMIC) + set(_req_libraries "${CMAKE_REQUIRED_LIBRARIES}") +- find_library(atomic_LIB atomic REQUIRED) ++ set(atomic_LIB "-latomic") + set(CMAKE_REQUIRED_LIBRARIES ${atomic_LIB}) + check_cxx_source_compiles("${atomic_test_sources}" HAVE_STDATOMIC_WITH_LIB) + set(CMAKE_REQUIRED_LIBRARIES "${_req_libraries}") +-- +2.35.1 +