Source: qt6-base
Version: 6.4.2+dfsg-21
Severity: wishlist
Tags: ftbfs patch
User: debian-loonga...@lists.debian.org
Usertags: loong64
Dear maintainers,
We need to add architectural support for qt6-base. Otherwise it will
build failures [1].
[1]:https://buildd.debian.org/status/fetch.php?pkg=qt6-base&arch=loong64&ver=6.4.2%2Bdfsg-21&stamp=1705160701&raw=0
BTW, A recent query revealed that LoongArch architecture is now
supported by the upstream[2] and [3].
Please consider the patch I have attached. Or pull full support from
upstream.
Would it be possible to include the support for LoongArch in the next
upload?
If you have any questions, you can contact me at any time.
[2]:https://code.qt.io/cgit/qt/qtbase.git/commit/?id=bdc16f086f1664b56d8add0691c9a80d7997efd9
[3]:https://code.qt.io/cgit/qt/qtbase.git/commit/?id=0ab51dcc3c0cca0d84822f3871d98ffa46b6b2e4
thanks,
Ding Song
>From 048b5fb8be109f67a48547d40d2bb53a7272ac2e Mon Sep 17 00:00:00 2001
From: Ding Song <songd...@loongson.cn>
Date: Sun, 4 Feb 2024 14:46:11 +0800
Subject: [PATCH] Add LoongArch detection
---
src/3rdparty/forkfd/forkfd_linux.c | 3 ++-
src/corelib/global/archdetect.cpp | 4 +++
src/corelib/global/qglobal.cpp | 34 ++++++++++++++++++++++++
src/corelib/global/qprocessordetection.h | 14 ++++++++++
src/corelib/plugin/qelfparser_p.cpp | 5 ++++
5 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/src/3rdparty/forkfd/forkfd_linux.c b/src/3rdparty/forkfd/forkfd_linux.c
index fea80b0e..25491ae0 100644
--- a/src/3rdparty/forkfd/forkfd_linux.c
+++ b/src/3rdparty/forkfd/forkfd_linux.c
@@ -84,7 +84,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
#elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
- defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
+ defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
+ defined(__loongarch__)
/* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
* but since both values are 0, there's no harm. */
return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
diff --git a/src/corelib/global/archdetect.cpp b/src/corelib/global/archdetect.cpp
index 188ec2d1..0c08393a 100644
--- a/src/corelib/global/archdetect.cpp
+++ b/src/corelib/global/archdetect.cpp
@@ -25,6 +25,10 @@
# define ARCH_PROCESSOR "x86_64"
#elif defined(Q_PROCESSOR_IA64)
# define ARCH_PROCESSOR "ia64"
+#elif defined(Q_PROCESSOR_LOONGARCH_32)
+# define ARCH_PROCESSOR "loongarch32"
+#elif defined(Q_PROCESSOR_LOONGARCH_64)
+# define ARCH_PROCESSOR "loongarch64"
#elif defined(Q_PROCESSOR_M68K)
# define ARCH_PROCESSOR "m68k"
#elif defined(Q_PROCESSOR_MIPS_64)
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index f17b0492..20b0a693 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1809,6 +1809,40 @@ bool qSharedBuild() noexcept
\sa QSysInfo::buildCpuArchitecture()
*/
+/*!
+ \macro Q_PROCESSOR_LOONGARCH
+ \relates <QtProcessorDetection>
+ \since 6.5
+
+ Defined if the application is compiled for LoongArch processors.
+
+ \sa QSysInfo::buildCpuArchitecture()
+*/
+
+/*!
+ \macro Q_PROCESSOR_LOONGARCH_32
+ \relates <QtProcessorDetection>
+ \since 6.5
+
+ Defined if the application is compiled for 32-bit LoongArch processors.
+ The \l Q_PROCESSOR_LOONGARCH macro is also defined when
+ Q_PROCESSOR_LOONGARCH_32 is defined.
+
+ \sa QSysInfo::buildCpuArchitecture()
+*/
+
+/*!
+ \macro Q_PROCESSOR_LOONGARCH_64
+ \relates <QtProcessorDetection>
+ \since 6.5
+
+ Defined if the application is compiled for 64-bit LoongArch processors.
+ The \l Q_PROCESSOR_LOONGARCH macro is also defined when
+ Q_PROCESSOR_LOONGARCH_64 is defined.
+
+ \sa QSysInfo::buildCpuArchitecture()
+*/
+
/*!
\macro Q_PROCESSOR_M68K
\relates <QtGlobal>
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index 94a1ea29..90ff372a 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -196,6 +196,20 @@
# define Q_PROCESSOR_WORDSIZE 8
// Q_BYTE_ORDER not defined, use endianness auto-detection
+/*
+ LoongArch family, known variants: 32- and 64-bit
+
+ LoongArch is little-endian.
+*/
+#elif defined(__loongarch__)
+# define Q_PROCESSOR_LOONGARCH
+# if __loongarch_grlen == 64
+# define Q_PROCESSOR_LOONGARCH_64
+# else
+# define Q_PROCESSOR_LOONGARCH_32
+# endif
+# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
+
/*
Motorola 68000 family, no revisions or variants
diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp
index 71457fac..54e5a19e 100644
--- a/src/corelib/plugin/qelfparser_p.cpp
+++ b/src/corelib/plugin/qelfparser_p.cpp
@@ -124,6 +124,8 @@ struct ElfMachineCheck
EM_PARISC
#elif defined(Q_PROCESSOR_IA64)
EM_IA_64
+#elif defined(Q_PROCESSOR_LOONGARCH)
+ EM_LOONGARCH
#elif defined(Q_PROCESSOR_M68K)
EM_68K
#elif defined(Q_PROCESSOR_MIPS)
@@ -390,6 +392,9 @@ Q_DECL_UNUSED Q_DECL_COLD_FUNCTION static QDebug &operator<<(QDebug &d, ElfHeade
case EM_BLACKFIN: d << ", Blackfin"; break;
#endif
case EM_IA_64: d << ", IA-64"; break;
+#ifdef EM_LOONGARCH
+ case EM_LOONGARCH: d << ", LoongArch"; break;
+#endif
case EM_MIPS: d << ", MIPS"; break;
case EM_PARISC: d << ", HPPA"; break;
case EM_PPC: d << ", PowerPC"; break;
--
2.43.0