From de3cab7ca2fef0e365ae1ed47d192e8aee7ebcad Mon Sep 17 00:00:00 2001 From: Wenlong Zhang Date: Tue, 2 Apr 2024 02:41:52 +0000 Subject: [PATCH] add loongarch64 support for ceph-17.2.5 --- ...add-loongarch64-support-for-CxxFlags.patch | 25 + ...d-loongarch64-support-for-boost-1.74.patch | 608 ++++++++++++++++++ ...arch64-support-for-double-conversion.patch | 24 + ...d-loongarch64-support-for-fast_float.patch | 24 + 0005-add-loongarch64-support-for-pmdk.patch | 318 +++++++++ ceph.spec | 18 +- 6 files changed, 1015 insertions(+), 2 deletions(-) create mode 100644 0001-add-loongarch64-support-for-CxxFlags.patch create mode 100644 0002-add-loongarch64-support-for-boost-1.74.patch create mode 100644 0003-add-loongarch64-support-for-double-conversion.patch create mode 100644 0004-add-loongarch64-support-for-fast_float.patch create mode 100644 0005-add-loongarch64-support-for-pmdk.patch diff --git a/0001-add-loongarch64-support-for-CxxFlags.patch b/0001-add-loongarch64-support-for-CxxFlags.patch new file mode 100644 index 0000000..3cba516 --- /dev/null +++ b/0001-add-loongarch64-support-for-CxxFlags.patch @@ -0,0 +1,25 @@ +From c3a1a244534f5de172b92ee055952308d81f7456 Mon Sep 17 00:00:00 2001 +From: Wenlong Zhang +Date: Wed, 24 Jan 2024 02:38:41 +0000 +Subject: [PATCH 1/5] add loongarch64 support for CxxFlags + +--- + src/arrow/cpp/cmake_modules/SetupCxxFlags.cmake | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/arrow/cpp/cmake_modules/SetupCxxFlags.cmake b/src/arrow/cpp/cmake_modules/SetupCxxFlags.cmake +index c1a1ba043..2dd752d99 100644 +--- a/src/arrow/cpp/cmake_modules/SetupCxxFlags.cmake ++++ b/src/arrow/cpp/cmake_modules/SetupCxxFlags.cmake +@@ -28,6 +28,8 @@ if(NOT DEFINED ARROW_CPU_FLAG) + set(ARROW_CPU_FLAG "armv8") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7") + set(ARROW_CPU_FLAG "armv7") ++ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "loongarch64") ++ set(ARROW_CPU_FLAG "loongarch64") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "powerpc|ppc") + set(ARROW_CPU_FLAG "ppc") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "s390x") +-- +2.41.0 + diff --git a/0002-add-loongarch64-support-for-boost-1.74.patch b/0002-add-loongarch64-support-for-boost-1.74.patch new file mode 100644 index 0000000..eae719b --- /dev/null +++ b/0002-add-loongarch64-support-for-boost-1.74.patch @@ -0,0 +1,608 @@ +From cafdc5039a6f00a0a0ee4509e3e58f7f17f932b0 Mon Sep 17 00:00:00 2001 +From: Wenlong Zhang +Date: Mon, 29 Jan 2024 07:51:21 +0000 +Subject: [PATCH] add loongarch64 support for boost-1.74 + +--- + src/boost/boost/predef/architecture.h | 1 + + .../boost/predef/architecture/loongarch.h | 41 ++++++ + src/boost/boost/predef/other/endian.h | 4 +- + src/boost/boostcpp.jam | 5 +- + .../config/checks/architecture/Jamroot.jam | 1 + + .../config/checks/architecture/loongarch.cpp | 12 ++ + src/boost/libs/context/build/Jamfile.v2 | 26 ++++ + src/boost/libs/context/build/architecture.jam | 4 + + .../src/asm/jump_loongarch64_lp64_elf_gas.S | 117 ++++++++++++++++++ + .../src/asm/make_loongarch64_lp64_elf_gas.S | 85 +++++++++++++ + .../src/asm/ontop_loongarch64_lp64_elf_gas.S | 117 ++++++++++++++++++ + src/boost/tools/build/src/engine/jam.h | 4 + + src/boost/tools/build/src/tools/builtin.py | 3 + + .../tools/features/architecture-feature.jam | 3 + + 14 files changed, 420 insertions(+), 3 deletions(-) + create mode 100644 src/boost/boost/predef/architecture/loongarch.h + create mode 100644 src/boost/libs/config/checks/architecture/loongarch.cpp + create mode 100644 src/boost/libs/context/src/asm/jump_loongarch64_lp64_elf_gas.S + create mode 100644 src/boost/libs/context/src/asm/make_loongarch64_lp64_elf_gas.S + create mode 100644 src/boost/libs/context/src/asm/ontop_loongarch64_lp64_elf_gas.S + +diff --git a/src/boost/boost/predef/architecture.h b/src/boost/boost/predef/architecture.h +index 732d6f0e5..647d55b66 100644 +--- a/src/boost/boost/predef/architecture.h ++++ b/src/boost/boost/predef/architecture.h +@@ -15,6 +15,7 @@ http://www.boost.org/LICENSE_1_0.txt) + #include + #include + #include ++#include + #include + #include + #include +diff --git a/src/boost/boost/predef/architecture/loongarch.h b/src/boost/boost/predef/architecture/loongarch.h +new file mode 100644 +index 000000000..2ad03f07b +--- /dev/null ++++ b/src/boost/boost/predef/architecture/loongarch.h +@@ -0,0 +1,41 @@ ++/* ++Copyright Zhang Na 2022 ++Distributed under the Boost Software License, Version 1.0. ++(See accompanying file LICENSE_1_0.txt or copy at ++http://www.boost.org/LICENSE_1_0.txt) ++*/ ++ ++#ifndef BOOST_PREDEF_ARCHITECTURE_LOONGARCH_H ++#define BOOST_PREDEF_ARCHITECTURE_LOONGARCH_H ++ ++#include ++#include ++ ++/* tag::reference[] ++= `BOOST_ARCH_LOONGARCH` ++[options="header"] ++|=== ++| {predef_symbol} | {predef_version} ++| `+__loongarch__+` | {predef_detection} ++|=== ++*/ // end::reference[] ++ ++#define BOOST_ARCH_LOONGARCH BOOST_VERSION_NUMBER_NOT_AVAILABLE ++ ++#if defined(__loongarch__) ++# undef BOOST_ARCH_LOONGARCH ++# define BOOST_ARCH_LOONGARCH BOOST_VERSION_NUMBER_AVAILABLE ++#endif ++ ++#if BOOST_ARCH_LOONGARCH ++# define BOOST_ARCH_LOONGARCH_AVAILABLE ++#endif ++ ++#define BOOST_ARCH_LOONGARCH_NAME "LoongArch" ++ ++#endif ++ ++#include ++#include ++BOOST_PREDEF_DECLARE_TEST(BOOST_ARCH_LOONGARCH,BOOST_ARCH_LOONGARCH_NAME) ++ +diff --git a/src/boost/boost/predef/other/endian.h b/src/boost/boost/predef/other/endian.h +index 0281e4a3f..5e2e3a0e4 100644 +--- a/src/boost/boost/predef/other/endian.h ++++ b/src/boost/boost/predef/other/endian.h +@@ -125,10 +125,12 @@ information and acquired knowledge: + defined(__ARMEL__) || \ + defined(__THUMBEL__) || \ + defined(__AARCH64EL__) || \ ++ defined(__loongarch__) || \ + defined(_MIPSEL) || \ + defined(__MIPSEL) || \ + defined(__MIPSEL__) || \ +- defined(__riscv) ++ defined(__riscv) || \ ++ defined(__loongarch64) + # undef BOOST_ENDIAN_LITTLE_BYTE + # define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE + # endif +diff --git a/src/boost/boostcpp.jam b/src/boost/boostcpp.jam +index 299401778..4dea30519 100644 +--- a/src/boost/boostcpp.jam ++++ b/src/boost/boostcpp.jam +@@ -607,7 +607,7 @@ rule address-model ( ) + return @boostcpp.deduce-address-model ; + } + +-local deducable-architectures = arm mips1 power riscv s390x sparc x86 combined ; ++local deducable-architectures = arm loongarch mips1 power riscv s390x sparc x86 combined ; + feature.feature deduced-architecture : $(deducable-architectures) : propagated optional composite hidden ; + for a in $(deducable-architectures) + { +@@ -618,9 +618,10 @@ rule deduce-architecture ( properties * ) + { + local result ; + local filtered = [ toolset-properties $(properties) ] ; +- local names = arm mips1 power riscv s390x sparc x86 combined ; ++ local names = arm loongarch mips1 power riscv s390x sparc x86 combined ; + local idx = [ configure.find-builds "default architecture" : $(filtered) + : /boost/architecture//arm ++ : /boost/architecture//loongarch + : /boost/architecture//mips1 + : /boost/architecture//power + : /boost/architecture//riscv +diff --git a/src/boost/libs/config/checks/architecture/Jamroot.jam b/src/boost/libs/config/checks/architecture/Jamroot.jam +index 0d3b5e7be..9677831bc 100644 +--- a/src/boost/libs/config/checks/architecture/Jamroot.jam ++++ b/src/boost/libs/config/checks/architecture/Jamroot.jam +@@ -17,6 +17,7 @@ obj 64 : 64.cpp ; + + obj arm : arm.cpp ; + obj combined : combined.cpp ; ++obj loongarch : loongarch.cpp ; + obj mips1 : mips1.cpp ; + obj power : power.cpp ; + obj riscv : riscv.cpp ; +diff --git a/src/boost/libs/config/checks/architecture/loongarch.cpp b/src/boost/libs/config/checks/architecture/loongarch.cpp +new file mode 100644 +index 000000000..ceddb33a0 +--- /dev/null ++++ b/src/boost/libs/config/checks/architecture/loongarch.cpp +@@ -0,0 +1,12 @@ ++// loongarch.cpp ++// ++// Copyright (c) 2012 Steven Watanabe ++// ++// Distributed under the Boost Software License Version 1.0. (See ++// accompanying file LICENSE_1_0.txt or copy at ++// http://www.boost.org/LICENSE_1_0.txt) ++ ++#if !defined(__loongarch__) ++#error "Not LoongArch" ++#endif ++ +diff --git a/src/boost/libs/context/build/Jamfile.v2 b/src/boost/libs/context/build/Jamfile.v2 +index d88fdbfa8..4af3e36f9 100644 +--- a/src/boost/libs/context/build/Jamfile.v2 ++++ b/src/boost/libs/context/build/Jamfile.v2 +@@ -81,6 +81,7 @@ local rule default_abi ( ) + else if [ os.platform ] = "ARM" { tmp = aapcs ; } + else if [ os.platform ] = "MIPS32" { tmp = o32 ; } + else if [ os.platform ] = "MIPS64" { tmp = n64 ; } ++ else if [ os.platform ] = "LOONGARCH64" { tmp = lp64 ; } + return $(tmp) ; + } + +@@ -90,6 +91,7 @@ feature.feature abi + ms + n32 + n64 ++ lp64 + o32 + o64 + sysv +@@ -181,6 +183,30 @@ alias asm_sources + msvc + ; + ++# LOONGARCH ++# LOONGARCH64/LP64/ELF ++alias asm_sources ++ : asm/make_loongarch64_lp64_elf_gas.S ++ asm/jump_loongarch64_lp64_elf_gas.S ++ asm/ontop_loongarch64_lp64_elf_gas.S ++ : lp64 ++ 64 ++ loongarch ++ elf ++ clang ++ ; ++ ++alias asm_sources ++ : asm/make_loongarch64_lp64_elf_gas.S ++ asm/jump_loongarch64_lp64_elf_gas.S ++ asm/ontop_loongarch64_lp64_elf_gas.S ++ : lp64 ++ 64 ++ loongarch ++ elf ++ gcc ++ ; ++ + # ARM64 + # ARM64/AAPCS/ELF + alias asm_sources +diff --git a/src/boost/libs/context/build/architecture.jam b/src/boost/libs/context/build/architecture.jam +index e00e61e57..523c9f5ec 100644 +--- a/src/boost/libs/context/build/architecture.jam ++++ b/src/boost/libs/context/build/architecture.jam +@@ -83,6 +83,10 @@ rule deduce-architecture ( properties * ) + { + return combined ; + } ++ else if [ configure.builds /boost/architecture//loongarch : $(properties) : loongarch ] ++ { ++ return loongarch ; ++ } + } + } + +diff --git a/src/boost/libs/context/src/asm/jump_loongarch64_lp64_elf_gas.S b/src/boost/libs/context/src/asm/jump_loongarch64_lp64_elf_gas.S +new file mode 100644 +index 000000000..a95a9eeb9 +--- /dev/null ++++ b/src/boost/libs/context/src/asm/jump_loongarch64_lp64_elf_gas.S +@@ -0,0 +1,117 @@ ++/* ++ Copyright loongson 2018. ++ Distributed under the Boost Software License, Version 1.0. ++ (See accompanying file LICENSE_1_0.txt or copy at ++ http://www.boost.org/LICENSE_1_0.txt) ++*/ ++ ++/******************************************************* ++ * * ++ * ------------------------------------------------- * ++ * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * ++ * ------------------------------------------------- * ++ * | 0 | 8 | 16 | 24 | * ++ * ------------------------------------------------- * ++ * | F24 | F25 | F26 | F27 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * ++ * ------------------------------------------------- * ++ * | 32 | 40 | 48 | 56 | * ++ * ------------------------------------------------- * ++ * | F28 | F29 | F30 | F31 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * ++ * ------------------------------------------------- * ++ * | 64 | 72 | 80 | 88 | * ++ * ------------------------------------------------- * ++ * | S0 | S1 | S2 | S3 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * ++ * ------------------------------------------------- * ++ * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * ++ * ------------------------------------------------- * ++ * | S4 | S5 | S6 | S7 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * ++ * ------------------------------------------------- * ++ * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * ++ * ------------------------------------------------- * ++ * | FP | GP | RA | PC | * ++ * ------------------------------------------------- * ++ * * ++ * *****************************************************/ ++ ++.file "jump_loongarch64_lp64_elf_gas.S" ++.text ++.globl jump_fcontext ++.align 3 ++.type jump_fcontext,@function ++jump_fcontext: ++ # reserve space on stack ++ addi.d $sp, $sp, -160 ++ ++ st.d $s0, $sp, 64 # save S0 ++ st.d $s1, $sp, 72 # save S1 ++ st.d $s2, $sp, 80 # save S2 ++ st.d $s3, $sp, 88 # save S3 ++ st.d $s4, $sp, 96 # save S4 ++ st.d $s5, $sp, 104 # save S5 ++ st.d $s6, $sp, 112 # save S6 ++ st.d $s7, $sp, 120 # save S7 ++ st.d $s8, $sp, 128 # save S8 ++ st.d $fp, $sp, 136 # save FP ++ st.d $ra, $sp, 144 # save RA ++ st.d $ra, $sp, 152 # save RA as PC ++ ++ ++ fst.d $fs0, $sp, 0 # save F24 ++ fst.d $fs1, $sp, 8 # save F25 ++ fst.d $fs2, $sp, 16 # save F26 ++ fst.d $fs3, $sp, 24 # save F27 ++ fst.d $fs4, $sp, 32 # save F28 ++ fst.d $fs5, $sp, 40 # save F29 ++ fst.d $fs6, $sp, 48 # save F30 ++ fst.d $fs7, $sp, 56 # save F31 ++ ++ # swap a0(new stack), sp(old stack) ++ xor $a0, $a0, $sp ++ xor $sp, $a0, $sp ++ xor $a0, $a0, $sp ++ ++ fld.d $fs0, $sp, 0 # restore F24 ++ fld.d $fs1, $sp, 8 # restore F25 ++ fld.d $fs2, $sp, 16 # restore F26 ++ fld.d $fs3, $sp, 24 # restore F27 ++ fld.d $fs4, $sp, 32 # restore F28 ++ fld.d $fs5, $sp, 40 # restore F29 ++ fld.d $fs6, $sp, 48 # restore F30 ++ fld.d $fs7, $sp, 56 # restore F31 ++ ++ ld.d $s0, $sp, 64 # restore S0 ++ ld.d $s1, $sp, 72 # restore S1 ++ ld.d $s2, $sp, 80 # restore S2 ++ ld.d $s3, $sp, 88 # restore S3 ++ ld.d $s4, $sp, 96 # restore S4 ++ ld.d $s5, $sp, 104 # restore S5 ++ ld.d $s6, $sp, 112 # restore S6 ++ ld.d $s7, $sp, 120 # restore S7 ++ ld.d $s8, $sp, 128 # restore S8 ++ ld.d $fp, $sp, 136 # restore FP ++ ld.d $ra, $sp, 144 # restore RA ++ ++ # load PC ++ ld.d $t8, $sp, 152 ++ ++ # adjust stack ++ addi.d $sp, $sp, 160 ++ ++ # jump to context ++ jr $t8 ++.size jump_fcontext, .-jump_fcontext ++ ++/* Mark that we don't need executable stack. */ ++.section .note.GNU-stack,"",%progbits +diff --git a/src/boost/libs/context/src/asm/make_loongarch64_lp64_elf_gas.S b/src/boost/libs/context/src/asm/make_loongarch64_lp64_elf_gas.S +new file mode 100644 +index 000000000..20106bee4 +--- /dev/null ++++ b/src/boost/libs/context/src/asm/make_loongarch64_lp64_elf_gas.S +@@ -0,0 +1,85 @@ ++/* ++ Copyright loongson 2018. ++ Distributed under the Boost Software License, Version 1.0. ++ (See accompanying file LICENSE_1_0.txt or copy at ++ http://www.boost.org/LICENSE_1_0.txt) ++*/ ++ ++/******************************************************* ++ * * ++ * ------------------------------------------------- * ++ * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * ++ * ------------------------------------------------- * ++ * | 0 | 8 | 16 | 24 | * ++ * ------------------------------------------------- * ++ * | F24 | F25 | F26 | F27 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * ++ * ------------------------------------------------- * ++ * | 32 | 40 | 48 | 56 | * ++ * ------------------------------------------------- * ++ * | F28 | F29 | F30 | F31 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * ++ * ------------------------------------------------- * ++ * | 64 | 72 | 80 | 88 | * ++ * ------------------------------------------------- * ++ * | S0 | S1 | S2 | S3 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * ++ * ------------------------------------------------- * ++ * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * ++ * ------------------------------------------------- * ++ * | S4 | S5 | S6 | S7 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * ++ * ------------------------------------------------- * ++ * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * ++ * ------------------------------------------------- * ++ * | FP | GP | RA | PC | * ++ * ------------------------------------------------- * ++ * * ++ * *****************************************************/ ++ ++.file "make_loongarch64_lp64_elf_gas.S" ++.text ++.globl make_fcontext ++.align 3 ++.type make_fcontext,@function ++make_fcontext: ++ # shift address in A0 to lower 16 byte boundary ++ li.w $t0, 0xfffffffffffffff0 ++ and $a0, $a0, $t0 ++ ++ # reserve space for context-data on context-stack ++ addi.d $a0, $a0, -160 ++ ++ # third arg of make_fcontext() == address of context-function ++ st.d $a2, $a0, 152 ++ ++ # save address of finish as return-address for context-function ++ # will be entered after context-function returns ++ la.local $t8, finish ++ st.d $t8, $a0, 144 ++ ++ # return pointer to context-data ++ jr $ra ++ ++finish: ++ # reload our gp register (needed for la) ++ addi.d $t0, $sp, -160 ++ ++ # call _exit(0) ++ # the previous function should have left the 16 bytes incoming argument ++ # area on the stack which we reuse for calling _exit ++ la.global $t8, _exit ++ move $a0, $zero ++ jr $t8 ++.size make_fcontext, .-make_fcontext ++ ++/* Mark that we don't need executable stack. */ ++.section .note.GNU-stack,"",%progbits +diff --git a/src/boost/libs/context/src/asm/ontop_loongarch64_lp64_elf_gas.S b/src/boost/libs/context/src/asm/ontop_loongarch64_lp64_elf_gas.S +new file mode 100644 +index 000000000..3f976fcfe +--- /dev/null ++++ b/src/boost/libs/context/src/asm/ontop_loongarch64_lp64_elf_gas.S +@@ -0,0 +1,117 @@ ++/* ++ Copyright loongson 2018. ++ Distributed under the Boost Software License, Version 1.0. ++ (See accompanying file LICENSE_1_0.txt or copy at ++ http://www.boost.org/LICENSE ++*/ ++ ++/******************************************************* ++ * * ++ * ------------------------------------------------- * ++ * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * ++ * ------------------------------------------------- * ++ * | 0 | 8 | 16 | 24 | * ++ * ------------------------------------------------- * ++ * | F24 | F25 | F26 | F27 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * ++ * ------------------------------------------------- * ++ * | 32 | 40 | 48 | 56 | * ++ * ------------------------------------------------- * ++ * | F28 | F29 | F30 | F31 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * ++ * ------------------------------------------------- * ++ * | 64 | 72 | 80 | 88 | * ++ * ------------------------------------------------- * ++ * | S0 | S1 | S2 | S3 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * ++ * ------------------------------------------------- * ++ * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * ++ * ------------------------------------------------- * ++ * | S4 | S5 | S6 | S7 | * ++ * ------------------------------------------------- * ++ * ------------------------------------------------- * ++ * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * ++ * ------------------------------------------------- * ++ * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * ++ * ------------------------------------------------- * ++ * | FP | GP | RA | PC | * ++ * ------------------------------------------------- * ++ * * ++ * *****************************************************/ ++ ++.file "ontop_loongarch64_lp64_elf_gas.S" ++.text ++.globl ontop_fcontext ++.align 3 ++.type ontop_fcontext,@function ++ontop_fcontext: ++ # reserve space on stack ++ addi.d $sp, $sp, -160 ++ ++ st.d $s0, $sp, 64 # save S0 ++ st.d $s1, $sp, 72 # save S1 ++ st.d $s2, $sp, 80 # save S2 ++ st.d $s3, $sp, 88 # save S3 ++ st.d $s4, $sp, 96 # save S4 ++ st.d $s5, $sp, 104 # save S5 ++ st.d $s6, $sp, 112 # save S6 ++ st.d $s7, $sp, 120 # save S7 ++ st.d $s8, $sp, 128 # save S8 ++ st.d $fp, $sp, 136 # save FP ++ st.d $ra, $sp, 144 # save RA ++ st.d $ra, $sp, 152 # save RA as PC ++ ++ ++ fst.d $fs0, $sp, 0 # save F24 ++ fst.d $fs1, $sp, 8 # save F25 ++ fst.d $fs2, $sp, 16 # save F26 ++ fst.d $fs3, $sp, 24 # save F27 ++ fst.d $fs4, $sp, 32 # save F28 ++ fst.d $fs5, $sp, 40 # save F29 ++ fst.d $fs6, $sp, 48 # save F30 ++ fst.d $fs7, $sp, 56 # save F31 ++ ++ # swap a0,sp ++ xor $a0, $a0, $sp ++ xor $sp, $a0, $sp ++ xor $a0, $a0, $sp ++ ++ fld.d $fs0, $sp, 0 # restore F24 ++ fld.d $fs1, $sp, 8 # restore F25 ++ fld.d $fs2, $sp, 16 # restore F26 ++ fld.d $fs3, $sp, 24 # restore F27 ++ fld.d $fs4, $sp, 32 # restore F28 ++ fld.d $fs5, $sp, 40 # restore F29 ++ fld.d $fs6, $sp, 48 # restore F30 ++ fld.d $fs7, $sp, 56 # restore F31 ++ ++ ld.d $s0, $sp, 64 # restore S0 ++ ld.d $s1, $sp, 72 # restore S1 ++ ld.d $s2, $sp, 80 # restore S2 ++ ld.d $s3, $sp, 88 # restore S3 ++ ld.d $s4, $sp, 96 # restore S4 ++ ld.d $s5, $sp, 104 # restore S5 ++ ld.d $s6, $sp, 112 # restore S6 ++ ld.d $s7, $sp, 120 # restore S7 ++ ld.d $s8, $sp, 128 # restore S8 ++ ld.d $fp, $sp, 136 # restore FP ++ ld.d $ra, $sp, 144 # restore RA ++ ++ # load PC ++ move $t8, $a2 ++ ++ # adjust stack ++ addi.d $sp, $sp, 160 ++ ++ # jump to context ++ jr $t8 ++.size ontop_fcontext, .-ontop_fcontext ++ ++/* Mark that we don't need executable stack. */ ++.section .note.GNU-stack,"",%progbits +diff --git a/src/boost/tools/build/src/engine/jam.h b/src/boost/tools/build/src/engine/jam.h +index 984a4a41b..d520d154d 100644 +--- a/src/boost/tools/build/src/engine/jam.h ++++ b/src/boost/tools/build/src/engine/jam.h +@@ -432,6 +432,10 @@ + #define OSPLAT "OSPLAT=PARISC" + #endif + ++#ifdef __loongarch64 ++ #define OSPLAT "OSPLAT=LOONGARCH64" ++#endif ++ + #ifndef OSPLAT + #define OSPLAT "" + #endif +diff --git a/src/boost/tools/build/src/tools/builtin.py b/src/boost/tools/build/src/tools/builtin.py +index 9eeaaf697..25899796b 100644 +--- a/src/boost/tools/build/src/tools/builtin.py ++++ b/src/boost/tools/build/src/tools/builtin.py +@@ -270,6 +270,9 @@ def register_globals (): + # Advanced RISC Machines + 'arm', + ++ # loongarch ++ loongarch64 ++ + # z Systems (aka s390x) + 's390x', + +diff --git a/src/boost/tools/build/src/tools/features/architecture-feature.jam b/src/boost/tools/build/src/tools/features/architecture-feature.jam +index 3e3ca382f..34dade5b0 100644 +--- a/src/boost/tools/build/src/tools/features/architecture-feature.jam ++++ b/src/boost/tools/build/src/tools/features/architecture-feature.jam +@@ -42,6 +42,9 @@ feature.feature architecture + # RISC-V + riscv + ++ # loongarch ++ loongarch ++ + # z Systems (aka s390x) + s390x + +-- +2.41.0 + diff --git a/0003-add-loongarch64-support-for-double-conversion.patch b/0003-add-loongarch64-support-for-double-conversion.patch new file mode 100644 index 0000000..45193fa --- /dev/null +++ b/0003-add-loongarch64-support-for-double-conversion.patch @@ -0,0 +1,24 @@ +From 7171a5fdbb69a06f4060cd02d692c228fe64d128 Mon Sep 17 00:00:00 2001 +From: Wenlong Zhang +Date: Wed, 24 Jan 2024 02:43:47 +0000 +Subject: [PATCH 3/5] add loongarch64 support for double-conversion + +--- + src/arrow/cpp/src/arrow/vendored/double-conversion/utils.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/arrow/cpp/src/arrow/vendored/double-conversion/utils.h b/src/arrow/cpp/src/arrow/vendored/double-conversion/utils.h +index 4328344d7..e7b4b3751 100644 +--- a/src/arrow/cpp/src/arrow/vendored/double-conversion/utils.h ++++ b/src/arrow/cpp/src/arrow/vendored/double-conversion/utils.h +@@ -101,6 +101,7 @@ int main(int argc, char** argv) { + defined(_MIPS_ARCH_MIPS32R2) || defined(__ARMEB__) ||\ + defined(__AARCH64EL__) || defined(__aarch64__) || defined(__AARCH64EB__) || \ + defined(__riscv) || \ ++ defined(__loongarch64) || \ + defined(__or1k__) || defined(__arc__) || \ + defined(__EMSCRIPTEN__) + #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1 +-- +2.41.0 + diff --git a/0004-add-loongarch64-support-for-fast_float.patch b/0004-add-loongarch64-support-for-fast_float.patch new file mode 100644 index 0000000..143243a --- /dev/null +++ b/0004-add-loongarch64-support-for-fast_float.patch @@ -0,0 +1,24 @@ +From 9b557947041d8e6c97cb4a0d39f25c1331a0866f Mon Sep 17 00:00:00 2001 +From: Wenlong Zhang +Date: Wed, 24 Jan 2024 02:44:45 +0000 +Subject: [PATCH 4/5] add loongarch64 support for fast_float + +--- + src/arrow/cpp/src/arrow/vendored/fast_float/float_common.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/arrow/cpp/src/arrow/vendored/fast_float/float_common.h b/src/arrow/cpp/src/arrow/vendored/fast_float/float_common.h +index f7b7662b9..117a5d455 100644 +--- a/src/arrow/cpp/src/arrow/vendored/fast_float/float_common.h ++++ b/src/arrow/cpp/src/arrow/vendored/fast_float/float_common.h +@@ -9,6 +9,7 @@ + || defined(__amd64) || defined(__aarch64__) || defined(_M_ARM64) \ + || defined(__MINGW64__) \ + || defined(__s390x__) \ ++ || defined(__loongarch64) \ + || (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)) \ + || defined(__EMSCRIPTEN__)) + #define FASTFLOAT_64BIT +-- +2.41.0 + diff --git a/0005-add-loongarch64-support-for-pmdk.patch b/0005-add-loongarch64-support-for-pmdk.patch new file mode 100644 index 0000000..537e913 --- /dev/null +++ b/0005-add-loongarch64-support-for-pmdk.patch @@ -0,0 +1,318 @@ +From 09853de6dd976aea74309d38741c956c38767ba8 Mon Sep 17 00:00:00 2001 +From: Wenlong Zhang +Date: Wed, 24 Jan 2024 02:46:29 +0000 +Subject: [PATCH 5/5] add loongarch64 support for pmdk + +--- + src/pmdk/src/Makefile.inc | 2 +- + src/pmdk/src/common/page_size.h | 4 ++ + src/pmdk/src/common/pool_hdr.c | 4 ++ + src/pmdk/src/common/pool_hdr.h | 1 + + src/pmdk/src/common/uuid.c | 2 +- + src/pmdk/src/core/util.h | 24 ++++++++++- + src/pmdk/src/core/valgrind_internal.h | 2 +- + src/pmdk/src/include/libpmemblk.h | 2 +- + src/pmdk/src/libpmem2/badblocks_ndctl.c | 2 +- + src/pmdk/src/libpmem2/loongarch64/flags.inc | 11 +++++ + src/pmdk/src/libpmem2/loongarch64/init.c | 41 +++++++++++++++++++ + .../libpmem2/loongarch64/loongarch_cacheops.h | 14 +++++++ + src/pmdk/src/libpmem2/loongarch64/sources.inc | 8 ++++ + .../src/libpmem2/region_namespace_ndctl.c | 3 +- + src/pmdk/src/libpmem2/usc_ndctl.c | 2 +- + src/pmdk/src/tools/daxio/daxio.c | 2 +- + 16 files changed, 115 insertions(+), 9 deletions(-) + create mode 100644 src/pmdk/src/libpmem2/loongarch64/flags.inc + create mode 100644 src/pmdk/src/libpmem2/loongarch64/init.c + create mode 100644 src/pmdk/src/libpmem2/loongarch64/loongarch_cacheops.h + create mode 100644 src/pmdk/src/libpmem2/loongarch64/sources.inc + +diff --git a/src/pmdk/src/Makefile.inc b/src/pmdk/src/Makefile.inc +index 04ab0192f..a718ecf6f 100644 +--- a/src/pmdk/src/Makefile.inc ++++ b/src/pmdk/src/Makefile.inc +@@ -146,7 +146,7 @@ ifneq ($(TESTBUILD), 1) + $(error "$(TESTCMD)" failed) + endif + +-ifeq ($(filter $(ARCH), x86_64 aarch64 ppc64),) ++ifeq ($(filter $(ARCH), x86_64 aarch64 ppc64 loongarch64),) + $(error unsupported architecture: $(ARCH)) + endif + +diff --git a/src/pmdk/src/common/page_size.h b/src/pmdk/src/common/page_size.h +index 978eb33c6..deb2d41e2 100644 +--- a/src/pmdk/src/common/page_size.h ++++ b/src/pmdk/src/common/page_size.h +@@ -13,6 +13,10 @@ + + #define PMEM_PAGESIZE 65536 + ++#elif defined(__loongarch64) ++ ++#define PMEM_PAGESIZE 16384 ++ + #else + + #error unable to recognize ISA at compile time +diff --git a/src/pmdk/src/common/pool_hdr.c b/src/pmdk/src/common/pool_hdr.c +index dc6985f09..882d53dc3 100644 +--- a/src/pmdk/src/common/pool_hdr.c ++++ b/src/pmdk/src/common/pool_hdr.c +@@ -28,6 +28,10 @@ + #define PMDK_MACHINE PMDK_MACHINE_PPC64 + #define PMDK_MACHINE_CLASS PMDK_MACHINE_CLASS_64 + ++#elif defined(__loongarch64) ++#define PMDK_MACHINE PMDK_MACHINE_LOONGARCH64 ++#define PMDK_MACHINE_CLASS PMDK_MACHINE_CLASS_64 ++ + #else + /* add appropriate definitions here when porting PMDK to another ISA */ + #error unable to recognize ISA at compile time +diff --git a/src/pmdk/src/common/pool_hdr.h b/src/pmdk/src/common/pool_hdr.h +index eb7e90753..fbe28e379 100644 +--- a/src/pmdk/src/common/pool_hdr.h ++++ b/src/pmdk/src/common/pool_hdr.h +@@ -77,6 +77,7 @@ struct arch_flags { + #define PMDK_MACHINE_X86_64 62 + #define PMDK_MACHINE_AARCH64 183 + #define PMDK_MACHINE_PPC64 21 ++#define PMDK_MACHINE_LOONGARCH64 258 + + /* possible values of the data field in the above struct */ + #define PMDK_DATA_LE 1 /* 2's complement, little endian */ +diff --git a/src/pmdk/src/common/uuid.c b/src/pmdk/src/common/uuid.c +index 94fdd737c..da59208fb 100644 +--- a/src/pmdk/src/common/uuid.c ++++ b/src/pmdk/src/common/uuid.c +@@ -53,7 +53,7 @@ util_uuid_to_string(const uuid_t u, char *buf) + * f81d4fae-7dec-11d0-a765-00a0c91e6bf6 + */ + int +-util_uuid_from_string(const char *uuid, struct uuid *ud) ++util_uuid_from_string(const char uuid[POOL_HDR_UUID_STR_LEN], struct uuid *ud) + { + if (strlen(uuid) != 36) { + LOG(2, "invalid uuid string"); +diff --git a/src/pmdk/src/core/util.h b/src/pmdk/src/core/util.h +index bf6339ec0..533e1282c 100644 +--- a/src/pmdk/src/core/util.h ++++ b/src/pmdk/src/core/util.h +@@ -58,7 +58,7 @@ extern "C" { + extern unsigned long long Pagesize; + extern unsigned long long Mmap_align; + +-#if defined(__x86_64) || defined(_M_X64) || defined(__aarch64__) ++#if defined(__x86_64) || defined(_M_X64) || defined(__aarch64__) || defined(__loongarch64) + #define CACHELINE_SIZE 64ULL + #elif defined(__PPC64__) + #define CACHELINE_SIZE 128ULL +@@ -534,6 +534,28 @@ static + #define CHECK_FUNC_COMPATIBLE(func1, func2) do {} while (0) + #endif /* __GNUC__ */ + ++/* macro for counting the number of varargs (up to 9) */ ++#define COUNT(...)\ ++ COUNT_I(__VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1) ++#define COUNT_I(_, _9, _8, _7, _6, _5, _4, _3, _2, X, ...) X ++ ++/* concatenation macro */ ++#define GLUE(A, B) GLUE_I(A, B) ++#define GLUE_I(A, B) A##B ++ ++/* macro for suppresing errors from unused variables (up to 9) */ ++#define SUPPRESS_UNUSED(...)\ ++ GLUE(SUPPRESS_ARG_, COUNT(__VA_ARGS__))(__VA_ARGS__) ++#define SUPPRESS_ARG_1(X) (void) X ++#define SUPPRESS_ARG_2(X, ...) SUPPRESS_ARG_1(X); SUPPRESS_ARG_1(__VA_ARGS__) ++#define SUPPRESS_ARG_3(X, ...) SUPPRESS_ARG_1(X); SUPPRESS_ARG_2(__VA_ARGS__) ++#define SUPPRESS_ARG_4(X, ...) SUPPRESS_ARG_1(X); SUPPRESS_ARG_3(__VA_ARGS__) ++#define SUPPRESS_ARG_5(X, ...) SUPPRESS_ARG_1(X); SUPPRESS_ARG_4(__VA_ARGS__) ++#define SUPPRESS_ARG_6(X, ...) SUPPRESS_ARG_1(X); SUPPRESS_ARG_5(__VA_ARGS__) ++#define SUPPRESS_ARG_7(X, ...) SUPPRESS_ARG_1(X); SUPPRESS_ARG_6(__VA_ARGS__) ++#define SUPPRESS_ARG_8(X, ...) SUPPRESS_ARG_1(X); SUPPRESS_ARG_7(__VA_ARGS__) ++#define SUPPRESS_ARG_9(X, ...) SUPPRESS_ARG_1(X); SUPPRESS_ARG_8(__VA_ARGS__) ++ + #ifdef __cplusplus + } + #endif +diff --git a/src/pmdk/src/core/valgrind_internal.h b/src/pmdk/src/core/valgrind_internal.h +index 910421a9c..759b655e0 100644 +--- a/src/pmdk/src/core/valgrind_internal.h ++++ b/src/pmdk/src/core/valgrind_internal.h +@@ -8,7 +8,7 @@ + #ifndef PMDK_VALGRIND_INTERNAL_H + #define PMDK_VALGRIND_INTERNAL_H 1 + +-#if !defined(_WIN32) && !defined(__FreeBSD__) ++#if !defined(_WIN32) && !defined(__FreeBSD__) && !defined(__loongarch64) + #ifndef VALGRIND_ENABLED + #define VALGRIND_ENABLED 1 + #endif +diff --git a/src/pmdk/src/include/libpmemblk.h b/src/pmdk/src/include/libpmemblk.h +index 72f6fd5b0..1a59901c2 100644 +--- a/src/pmdk/src/include/libpmemblk.h ++++ b/src/pmdk/src/include/libpmemblk.h +@@ -72,7 +72,7 @@ const wchar_t *pmemblk_check_versionW(unsigned major_required, + /* XXX - unify minimum pool size for both OS-es */ + + #ifndef _WIN32 +-#if defined(__x86_64__) || defined(__M_X64__) || defined(__aarch64__) ++#if defined(__x86_64__) || defined(__M_X64__) || defined(__aarch64__) || defined(__loongarch64) + /* minimum pool size: 16MiB + 4KiB (minimum BTT size + mmap alignment) */ + #define PMEMBLK_MIN_POOL ((size_t)((1u << 20) * 16 + (1u << 10) * 8)) + #elif defined(__PPC64__) +diff --git a/src/pmdk/src/libpmem2/badblocks_ndctl.c b/src/pmdk/src/libpmem2/badblocks_ndctl.c +index 76f724c12..b4da3b8ba 100644 +--- a/src/pmdk/src/libpmem2/badblocks_ndctl.c ++++ b/src/pmdk/src/libpmem2/badblocks_ndctl.c +@@ -16,7 +16,7 @@ + #include + #include + #include +-#include ++#include + + #include "libpmem2.h" + #include "pmem2_utils.h" +diff --git a/src/pmdk/src/libpmem2/loongarch64/flags.inc b/src/pmdk/src/libpmem2/loongarch64/flags.inc +new file mode 100644 +index 000000000..f7eaa8867 +--- /dev/null ++++ b/src/pmdk/src/libpmem2/loongarch64/flags.inc +@@ -0,0 +1,11 @@ ++# SPDX-License-Identifier: BSD-3-Clause ++# Copyright 2022, Intel Corporation ++ ++# ++# src/libpmem2/loongarch64/flags.inc -- flags for libpmem2/loongarch64 ++# ++ ++vpath %.c $(TOP)/src/libpmem2/loongarch64 ++vpath %.h $(TOP)/src/libpmem2/loongarch64 ++ ++CFLAGS += -Iloongarch64 +diff --git a/src/pmdk/src/libpmem2/loongarch64/init.c b/src/pmdk/src/libpmem2/loongarch64/init.c +new file mode 100644 +index 000000000..6b5572ae1 +--- /dev/null ++++ b/src/pmdk/src/libpmem2/loongarch64/init.c +@@ -0,0 +1,41 @@ ++// SPDX-License-Identifier: BSD-3-Clause ++/* Copyright 2022, Intel Corporation */ ++ ++#include ++ ++#include "auto_flush.h" ++#include "out.h" ++#include "pmem2_arch.h" ++#include "loongarch_cacheops.h" ++ ++/* ++ * memory_barrier -- (internal) issue the fence instruction ++ */ ++static void ++loongarch_memory_fence(void) ++{ ++ LOG(15, NULL); ++ loongarch_store_memory_barrier(); ++} ++ ++/* ++ * The Cache coherency maintenance between the instruction Cache and the data ++ * Cache within the processor core can be implemented by hardware maintenance. ++ */ ++static void ++loongarch_flush(const void *addr, size_t len) ++{ ++ SUPPRESS_UNUSED(addr, len); ++} ++ ++/* ++ * pmem2_arch_init -- initialize architecture-specific list of pmem operations ++ */ ++void ++pmem2_arch_init(struct pmem2_arch_info *info) ++{ ++ LOG(3, NULL); ++ ++ info->fence = loongarch_memory_fence; ++ info->flush = loongarch_flush; ++} +diff --git a/src/pmdk/src/libpmem2/loongarch64/loongarch_cacheops.h b/src/pmdk/src/libpmem2/loongarch64/loongarch_cacheops.h +new file mode 100644 +index 000000000..5084c113c +--- /dev/null ++++ b/src/pmdk/src/libpmem2/loongarch64/loongarch_cacheops.h +@@ -0,0 +1,14 @@ ++/* SPDX-License-Identifier: BSD-3-Clause */ ++/* Copyright 2022, Intel Corporation */ ++ ++#ifndef LOONGARCH64_CACHEOPS_H ++#define LOONGARCH64_CACHEOPS_H ++ ++#include ++ ++static inline void ++loongarch_store_memory_barrier(void) ++{ ++ asm volatile("dbar 0" : : : "memory"); ++} ++#endif +diff --git a/src/pmdk/src/libpmem2/loongarch64/sources.inc b/src/pmdk/src/libpmem2/loongarch64/sources.inc +new file mode 100644 +index 000000000..d71b73c83 +--- /dev/null ++++ b/src/pmdk/src/libpmem2/loongarch64/sources.inc +@@ -0,0 +1,8 @@ ++# SPDX-License-Identifier: BSD-3-Clause ++# Copyright 2022, Intel Corporation ++ ++# ++# src/libpmem2/loongarch64/sources.inc -- list of files for libpmem2/loongarch64 ++# ++ ++LIBPMEM2_ARCH_SOURCE = init.c +diff --git a/src/pmdk/src/libpmem2/region_namespace_ndctl.c b/src/pmdk/src/libpmem2/region_namespace_ndctl.c +index 1383796a9..18736b924 100644 +--- a/src/pmdk/src/libpmem2/region_namespace_ndctl.c ++++ b/src/pmdk/src/libpmem2/region_namespace_ndctl.c +@@ -6,7 +6,8 @@ + */ + + #include +-#include ++#include ++ + #include + #include + +diff --git a/src/pmdk/src/libpmem2/usc_ndctl.c b/src/pmdk/src/libpmem2/usc_ndctl.c +index be63e879b..c58032a83 100644 +--- a/src/pmdk/src/libpmem2/usc_ndctl.c ++++ b/src/pmdk/src/libpmem2/usc_ndctl.c +@@ -5,7 +5,7 @@ + * usc_ndctl.c -- pmem2 usc function for platforms using ndctl + */ + #include +-#include ++#include + #include + #include + #include +diff --git a/src/pmdk/src/tools/daxio/daxio.c b/src/pmdk/src/tools/daxio/daxio.c +index 66cd0b7ae..7f2c89d48 100644 +--- a/src/pmdk/src/tools/daxio/daxio.c ++++ b/src/pmdk/src/tools/daxio/daxio.c +@@ -21,7 +21,7 @@ + #include + + #include +-#include ++#include + #include + + #include "util.h" +-- +2.41.0 + diff --git a/ceph.spec b/ceph.spec index 5028b87..812652f 100644 --- a/ceph.spec +++ b/ceph.spec @@ -1,4 +1,4 @@ -%define anolis_release 4 +%define anolis_release 5 %global _hardened_build 1 %bcond_with make_check @@ -13,7 +13,7 @@ %else %bcond_with rbd_rwl_cache %endif -%ifarch %{arm64} +%ifarch %{arm64} loongarch64 %bcond_with system_pmdk %else %bcond_without system_pmdk @@ -97,6 +97,13 @@ Patch1001: ceph-17.2.0-pybind-boost-1.74.patch Patch1002: ceph-17.2.5-boost-1.81.patch Patch1003: ceph-17.2.0-deprecated-boost.patch %endif + +#support for loongarch64 +Patch2000: 0001-add-loongarch64-support-for-CxxFlags.patch +Patch2001: 0002-add-loongarch64-support-for-boost-1.74.patch +Patch2002: 0003-add-loongarch64-support-for-double-conversion.patch +Patch2003: 0004-add-loongarch64-support-for-fast_float.patch +Patch2004: 0005-add-loongarch64-support-for-pmdk.patch ################################################################################# # dependencies that apply across all distro families ################################################################################# @@ -1944,6 +1951,13 @@ exit 0 %config %{_sysconfdir}/prometheus/ceph/ceph_default_alerts.yml %changelog +* Tue Apr 2 2024 Wenlong Zhang - 17.2.5-5 +- add loongarch64 support for double-conversion +- add loongarch64 support for fast_float +- add loongarch64 support for ARROW_CPU_FLAG +- add loongarch64 support for boost 1.74 +- add loongarch64 support for pmdk in ceph-17.2.5 + * Mon Mar 11 2024 Bo Ren - 17.2.5-4 - Rebuild with python3.11 - Fix Python 3.11 (PEP-620) incompatibility -- Gitee