From 5be8e687dcc709812029ca741f3bcf7c38b11e05 Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Sun, 7 Nov 2021 12:06:17 +0800 Subject: [PATCH] build: support loongarch64 platform Signed-off-by: Liwei Ge --- ...spr-anolis-support-loongarch64-build.patch | 170 ++++++++++++++++++ nspr.spec | 9 +- 2 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 1000-nspr-anolis-support-loongarch64-build.patch diff --git a/1000-nspr-anolis-support-loongarch64-build.patch b/1000-nspr-anolis-support-loongarch64-build.patch new file mode 100644 index 0000000..2444e31 --- /dev/null +++ b/1000-nspr-anolis-support-loongarch64-build.patch @@ -0,0 +1,170 @@ +Description: + TODO: Put a short summary on the line above and replace this paragraph + with a longer explanation of this change. Complete the meta-information + with other relevant fields (see below for details). To make it easier, the + information below has been extracted from the changelog. Adjust it or drop + it. + . + nspr (2:4.20-1.lnd.1) unstable; urgency=medium + . + * New upstream release. +Author: Nan xiongchao + +--- +The information above should follow the Patch Tagging Guidelines, please +checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here +are templates for supplementary fields that you might want to add: + +Origin: , +Bug: +Bug-Debian: https://bugs.debian.org/ +Bug-Ubuntu: https://launchpad.net/bugs/ +Forwarded: +Reviewed-By: +Last-Update: 2020-11-18 + +--- nspr-4.20.orig/nspr/pr/include/md/_linux.cfg ++++ nspr-4.20/nspr/pr/include/md/_linux.cfg +@@ -496,6 +496,103 @@ + #define PR_BYTES_PER_WORD_LOG2 2 + #define PR_BYTES_PER_DWORD_LOG2 3 + ++#elif defined(__loongarch__) ++ ++/* For _ABI64 */ ++#ifdef _LOONGARCH_SZLONG ++#define IS_LITTLE_ENDIAN 1 ++#undef IS_BIG_ENDIAN ++#else ++#error "Unknown LOONGARCH endianness." ++#endif ++ ++#if _LOONGARCH_SIM == _ABILP64 ++#define IS_64 ++ ++#define PR_BYTES_PER_BYTE 1 ++#define PR_BYTES_PER_SHORT 2 ++#define PR_BYTES_PER_INT 4 ++#define PR_BYTES_PER_INT64 8 ++#define PR_BYTES_PER_LONG 8 ++#define PR_BYTES_PER_FLOAT 4 ++#define PR_BYTES_PER_DOUBLE 8 ++#define PR_BYTES_PER_WORD 8 ++#define PR_BYTES_PER_DWORD 8 ++ ++#define PR_BITS_PER_BYTE 8 ++#define PR_BITS_PER_SHORT 16 ++#define PR_BITS_PER_INT 32 ++#define PR_BITS_PER_INT64 64 ++#define PR_BITS_PER_LONG 64 ++#define PR_BITS_PER_FLOAT 32 ++#define PR_BITS_PER_DOUBLE 64 ++#define PR_BITS_PER_WORD 64 ++ ++#define PR_BITS_PER_BYTE_LOG2 3 ++#define PR_BITS_PER_SHORT_LOG2 4 ++#define PR_BITS_PER_INT_LOG2 5 ++#define PR_BITS_PER_INT64_LOG2 6 ++#define PR_BITS_PER_LONG_LOG2 6 ++#define PR_BITS_PER_FLOAT_LOG2 5 ++#define PR_BITS_PER_DOUBLE_LOG2 6 ++#define PR_BITS_PER_WORD_LOG2 6 ++ ++#define PR_ALIGN_OF_SHORT 2 ++#define PR_ALIGN_OF_INT 4 ++#define PR_ALIGN_OF_LONG 8 ++#define PR_ALIGN_OF_INT64 8 ++#define PR_ALIGN_OF_FLOAT 4 ++#define PR_ALIGN_OF_DOUBLE 8 ++#define PR_ALIGN_OF_POINTER 8 ++#define PR_ALIGN_OF_WORD 8 ++ ++#define PR_BYTES_PER_WORD_LOG2 3 ++#define PR_BYTES_PER_DWORD_LOG2 3 ++ ++#else /* _ABI64 */ ++ ++#define PR_BYTES_PER_BYTE 1 ++#define PR_BYTES_PER_SHORT 2 ++#define PR_BYTES_PER_INT 4 ++#define PR_BYTES_PER_INT64 8 ++#define PR_BYTES_PER_LONG 4 ++#define PR_BYTES_PER_FLOAT 4 ++#define PR_BYTES_PER_DOUBLE 8 ++#define PR_BYTES_PER_WORD 4 ++#define PR_BYTES_PER_DWORD 8 ++ ++#define PR_BITS_PER_BYTE 8 ++#define PR_BITS_PER_SHORT 16 ++#define PR_BITS_PER_INT 32 ++#define PR_BITS_PER_INT64 64 ++#define PR_BITS_PER_LONG 32 ++#define PR_BITS_PER_FLOAT 32 ++#define PR_BITS_PER_DOUBLE 64 ++#define PR_BITS_PER_WORD 32 ++ ++#define PR_BITS_PER_BYTE_LOG2 3 ++#define PR_BITS_PER_SHORT_LOG2 4 ++#define PR_BITS_PER_INT_LOG2 5 ++#define PR_BITS_PER_INT64_LOG2 6 ++#define PR_BITS_PER_LONG_LOG2 5 ++#define PR_BITS_PER_FLOAT_LOG2 5 ++#define PR_BITS_PER_DOUBLE_LOG2 6 ++#define PR_BITS_PER_WORD_LOG2 5 ++ ++#define PR_ALIGN_OF_SHORT 2 ++#define PR_ALIGN_OF_INT 4 ++#define PR_ALIGN_OF_LONG 4 ++#define PR_ALIGN_OF_INT64 8 ++#define PR_ALIGN_OF_FLOAT 4 ++#define PR_ALIGN_OF_DOUBLE 8 ++#define PR_ALIGN_OF_POINTER 4 ++#define PR_ALIGN_OF_WORD 4 ++ ++#define PR_BYTES_PER_WORD_LOG2 2 ++#define PR_BYTES_PER_DWORD_LOG2 3 ++ ++#endif /* _ABI64 */ ++ + #elif defined(__mips__) + + /* For _ABI64 */ +--- nspr-4.20.orig/nspr/pr/include/md/_linux.h ++++ nspr-4.20/nspr/pr/include/md/_linux.h +@@ -37,6 +37,8 @@ + #define _PR_SI_ARCHITECTURE "sparc" + #elif defined(__i386__) + #define _PR_SI_ARCHITECTURE "x86" ++#elif defined(__loongarch__) ++#define _PR_SI_ARCHITECTURE "loongarch64" + #elif defined(__mips__) + #define _PR_SI_ARCHITECTURE "mips" + #elif defined(__arm__) +@@ -442,6 +444,18 @@ extern void _MD_CleanupBeforeExit(void); + #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */ + #define PR_NUM_GCREGS 6 + ++#elif defined(__loongarch__) ++/* Linux/LOONGARCH64 */ ++#if defined(__GLIBC__) && __GLIBC__ >= 2 ++#define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp ++#define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[0].__fp = (val)) ++#define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) ++#define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[0].__fp) ++#define _MD_SP_TYPE __ptr_t ++#else ++#error "Linux/LOONGARCH64 pre-glibc2 not supported yet" ++#endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */ ++ + #elif defined(__mips__) + /* Linux/MIPS */ + #if defined(__GLIBC__) && __GLIBC__ >= 2 +@@ -523,7 +537,7 @@ extern void _MD_CleanupBeforeExit(void); + _MD_SET_FP(_thread, 0); \ + } + +-#elif defined(__mips__) ++#elif defined(__mips__) || defined(__loongarch__) + + #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ + { \ diff --git a/nspr.spec b/nspr.spec index f3e731e..03ee0d7 100644 --- a/nspr.spec +++ b/nspr.spec @@ -1,4 +1,5 @@ %global nspr_version 4.32.0 +%define anolis_release .0.1 # The upstream omits the trailing ".0", while we need it for # consistency with the pkg-config version: @@ -11,7 +12,7 @@ rpm.define(string.format("nspr_archive_version %s", Summary: Netscape Portable Runtime Name: nspr Version: %{nspr_version} -Release: 1%{?dist} +Release: 1%{anolis_release}%{?dist} License: MPLv2.0 URL: http://ftp.mozilla.org/pub/nspr/releases/v${nspr_archive_version}/src Group: System Environment/Libraries @@ -26,6 +27,7 @@ Source1: nspr-config.xml Patch1: nspr-config-pc.patch Patch2: nspr-gcc-atomics.patch +Patch1000: 1000-nspr-anolis-support-loongarch64-build.patch %description NSPR provides platform independence for non-GUI operating system @@ -60,7 +62,7 @@ cp ./nspr/config/nspr-config.in ./nspr/config/nspr-config-pc.in pushd nspr %patch2 -p1 -b .gcc-atomics popd - +%patch1000 -p1 %build %define _configure ./nspr/configure %configure \ @@ -152,6 +154,9 @@ done %{_mandir}/man*/* %changelog +* Sun Nov 7 2021 Liwei Ge - 4.32.0-1.0.1 +- Support loongarch64 platform + * Thu Jun 17 2021 Bob Relyea - 4.32.0-1 - Update to NSPR 4.32 -- Gitee