Pre Merge pull request !113 from zhangwenlong01/openEuler-22.03-LTS

This commit is contained in:
zhangwenlong01 2023-01-11 02:03:20 +00:00 committed by Gitee
commit d7f05ace64
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 483 additions and 1 deletions

View File

@ -0,0 +1,467 @@
From 0c117efe905a79d82f5ec638dec6f315d9e3f41c Mon Sep 17 00:00:00 2001
From: Wenlong Zhang <zhangwenlong@loongson.cn>
Date: Tue, 10 Jan 2023 20:54:06 +0800
Subject: [PATCH] add boost context support for loongarch64
---
boost/predef/other/endian.h | 3 +-
libs/context/build/Jamfile.v2 | 26 ++++
.../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 ++++++++++++++++++
tools/build/src/engine/jam.h | 4 +
tools/build/src/tools/builtin.py | 3 +
.../tools/features/architecture-feature.jam | 3 +
8 files changed, 357 insertions(+), 1 deletion(-)
create mode 100644 libs/context/src/asm/jump_loongarch64_lp64_elf_gas.S
create mode 100644 libs/context/src/asm/make_loongarch64_lp64_elf_gas.S
create mode 100644 libs/context/src/asm/ontop_loongarch64_lp64_elf_gas.S
diff --git a/boost/predef/other/endian.h b/boost/predef/other/endian.h
index d8ec63ff5..4d0630af0 100644
--- a/boost/predef/other/endian.h
+++ b/boost/predef/other/endian.h
@@ -125,7 +125,8 @@ information and acquired knowledge:
defined(__MIPSEL) || \
defined(__MIPSEL__) || \
defined(__riscv) || \
- defined(__e2k__)
+ defined(__e2k__) || \
+ defined(__loongarch64)
# undef BOOST_ENDIAN_LITTLE_BYTE
# define BOOST_ENDIAN_LITTLE_BYTE BOOST_VERSION_NUMBER_AVAILABLE
# endif
diff --git a/libs/context/build/Jamfile.v2 b/libs/context/build/Jamfile.v2
index 30e959839..68e6981a7 100644
--- a/libs/context/build/Jamfile.v2
+++ b/libs/context/build/Jamfile.v2
@@ -83,6 +83,7 @@ local rule default_abi ( )
else if [ os.platform ] = "SW_64" { 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) ;
}
@@ -92,6 +93,7 @@ feature.feature abi
ms
n32
n64
+ lp64
o32
o64
sysv
@@ -207,6 +209,30 @@ alias asm_sources
<toolset>gcc
;
+# 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
+ : <abi>lp64
+ <address-model>64
+ <architecture>loongarch64
+ <binary-format>elf
+ <toolset>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
+ : <abi>lp64
+ <address-model>64
+ <architecture>loongarch64
+ <binary-format>elf
+ <toolset>gcc
+ ;
+
# ARM64
# ARM64/AAPCS/ELF
alias asm_sources
diff --git a/libs/context/src/asm/jump_loongarch64_lp64_elf_gas.S b/libs/context/src/asm/jump_loongarch64_lp64_elf_gas.S
new file mode 100644
index 000000000..a95a9eeb9
--- /dev/null
+++ b/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/libs/context/src/asm/make_loongarch64_lp64_elf_gas.S b/libs/context/src/asm/make_loongarch64_lp64_elf_gas.S
new file mode 100644
index 000000000..20106bee4
--- /dev/null
+++ b/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/libs/context/src/asm/ontop_loongarch64_lp64_elf_gas.S b/libs/context/src/asm/ontop_loongarch64_lp64_elf_gas.S
new file mode 100644
index 000000000..3f976fcfe
--- /dev/null
+++ b/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/tools/build/src/engine/jam.h b/tools/build/src/engine/jam.h
index 59e5f82c0..76a786979 100644
--- a/tools/build/src/engine/jam.h
+++ b/tools/build/src/engine/jam.h
@@ -446,6 +446,10 @@
#define OSPLAT "OSPLAT=PARISC"
#endif
+#ifdef __loongarch64
+ #define OSPLAT "OSPLAT=LOONGARCH64"
+#endif
+
#ifndef OSPLAT
#define OSPLAT ""
#endif
diff --git a/tools/build/src/tools/builtin.py b/tools/build/src/tools/builtin.py
index 0368f6520..02ba21013 100644
--- a/tools/build/src/tools/builtin.py
+++ b/tools/build/src/tools/builtin.py
@@ -276,6 +276,9 @@ def register_globals ():
# z Systems (aka s390x)
's390x',
+ # loongarch
+ 'loongarch64',
+
# Combined architectures for platforms/toolsets that support building for
# multiple architectures at once. "combined" would be the default multi-arch
# for the toolset.
diff --git a/tools/build/src/tools/features/architecture-feature.jam b/tools/build/src/tools/features/architecture-feature.jam
index e3203078e..1048feafd 100644
--- a/tools/build/src/tools/features/architecture-feature.jam
+++ b/tools/build/src/tools/features/architecture-feature.jam
@@ -45,6 +45,9 @@ feature.feature architecture
# RISC-V
riscv
+ # loongarch
+ loongarch64
+
# z Systems (aka s390x)
s390x
:
--
2.33.0

View File

@ -2,7 +2,7 @@
Name: boost
Version: 1.78.0
Release: 15
Release: 16
Summary: The free peer-reviewed portable C++ source libraries
License: Boost Software License 1.0
URL: http://www.boost.org
@ -30,6 +30,9 @@ Patch9000: boost-1.78-python-Update-call_method-hpp.patch
Patch9001: boost_1_78_0-sw.patch
Patch9002: boost-1.78-graph-Skip-performance-test.patch
Patch9003: boost-1.78-icl-Avoid-gcc-bugs.patch
%ifarch loongarch64
Patch9004: boost-1.78-add-boost-context-support-for-loongarch64.patch
%endif
Requires: %{name}-atomic%{?_isa} = %{version}-%{release}
Requires: %{name}-chrono%{?_isa} = %{version}-%{release}
@ -68,7 +71,9 @@ BuildRequires: openssl-devel
# optional libraries for iostreams
BuildRequires: bzip2-devel libzstd-devel xz-devel zlib-devel
# optional library for multiprecision
%ifnarch loongarch64
BuildRequires: libquadmath-devel libquadmath-static
%endif
# optional library for python3
BuildRequires: python3-numpy
# optional library for regex
@ -264,7 +269,9 @@ An implementation of the mandated C99/C++ preprocessor functionality.
Summary: The Boost C++ headers, shared and static development libraries
Requires: boost%{?_isa} = %{version}-%{release}
Requires: libicu-devel%{?_isa}
%ifnarch loongarch64
Requires: libquadmath-devel%{?_isa}
%endif
Provides: boost-static
Obsoletes: boost-static < %{version}
@ -301,8 +308,13 @@ cd status
--include-tests=algorithm,graph,intrusive,dynamic_bitset,property_map,crc,lexical_cast,range \
--exclude-tests=mpi,graph_parallel
../b2 %{?_smp_mflags} %{opt_feature} cxxflags="$RPM_OPT_FLAGS" %{boost_macros} \
%ifarch loongarch64
--include-tests=bimap,circular_buffer,container,heap,icl,logic,multi_array,multi_index,poly_collection,property_tree,ptr_container,sort \
--exclude-tests=container_hash,lockfree
%else
--include-tests=bimap,circular_buffer,container,heap,icl,lockfree,logic,multi_array,multi_index,poly_collection,property_tree,ptr_container,sort \
--exclude-tests=container_hash
%endif
%install
./b2 %{b2_options} \
@ -452,6 +464,9 @@ find libs -name example -exec cp {} boost-example --parents -r \;
%{_libdir}/*.a
%changelog
* Fri Jan 6 2023 Wenlong Zhang<zhangwenlong@loongson.cn> - 1.78.0-16
- add boost context support for loongarch64
* Mon Dec 12 2022 Liu Zixian <liuzixian4@huawei.com> - 1.78.0-15
- enable more regression tests to covers commonly used container libraries