From 1a018a2c3784117ae292a663bf3b8870a210358d Mon Sep 17 00:00:00 2001 From: panchenbo Date: Mon, 7 Aug 2023 11:00:51 +0800 Subject: [PATCH] add support for loongarch64 --- 0001-add-loongarch64-support.patch | 84 ++++++++++++++++++++++++++++++ opengauss-dcf.spec | 27 ++++------ 2 files changed, 95 insertions(+), 16 deletions(-) create mode 100644 0001-add-loongarch64-support.patch diff --git a/0001-add-loongarch64-support.patch b/0001-add-loongarch64-support.patch new file mode 100644 index 0000000..138ecaf --- /dev/null +++ b/0001-add-loongarch64-support.patch @@ -0,0 +1,84 @@ +From 8bc1a92d8f9275bf608ebf7b4b49cf64484f2d45 Mon Sep 17 00:00:00 2001 +From: herengui +Date: Mon, 22 May 2023 11:31:12 +0800 +Subject: [PATCH] add loongarch64 support + +Signed-off-by: herengui +--- + CMakeLists.txt | 2 ++ + src/common/cm_concurrency/cm_spinlock.h | 3 +++ + src/common/cm_concurrency/cm_thread.c | 2 +- + src/common/cm_utils/cm_checksum.h | 2 +- + src/common/cm_utils/cm_memory.h | 3 +++ + 5 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 81d310b..54ffffe 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -88,6 +88,8 @@ if (UNIX) + endif (USE_H1620) + + add_compile_options(-mtune=cortex-a72 -fsigned-char -g -ggdb3 -march=armv8-a+crc -funwind-tables) ++ elseif (OS_ARCH STREQUAL "loongarch64") ++ add_compile_options(-march=loongarch64 ) + else () + add_compile_options(-msse4.2 ) + endif () +diff --git a/src/common/cm_concurrency/cm_spinlock.h b/src/common/cm_concurrency/cm_spinlock.h +index 7965853..ef4755d 100644 +--- a/src/common/cm_concurrency/cm_spinlock.h ++++ b/src/common/cm_concurrency/cm_spinlock.h +@@ -68,6 +68,9 @@ typedef struct st_spin_statis { + { \ + __asm__ volatile("nop"); \ + } ++#elif defined(__loongarch__) ++#define fas_cpu_pause() \ ++ {} + #else + #define fas_cpu_pause() \ + { \ +diff --git a/src/common/cm_concurrency/cm_thread.c b/src/common/cm_concurrency/cm_thread.c +index 2d0aa2a..266abba 100644 +--- a/src/common/cm_concurrency/cm_thread.c ++++ b/src/common/cm_concurrency/cm_thread.c +@@ -294,7 +294,7 @@ uint32 cm_get_current_thread_id() + { + #if (defined __x86_64__) + #define __SYS_GET_SPID 186 +-#elif (defined __aarch64__) ++#elif defined(__aarch64__) || defined(__loongarch__) + #define __SYS_GET_SPID 178 + #endif + #define gettid() syscall(__SYS_GET_SPID) +diff --git a/src/common/cm_utils/cm_checksum.h b/src/common/cm_utils/cm_checksum.h +index 85bb9fa..8e05e5a 100644 +--- a/src/common/cm_utils/cm_checksum.h ++++ b/src/common/cm_utils/cm_checksum.h +@@ -26,7 +26,7 @@ + + #include "cm_defs.h" + +-#if defined(__arm__) || defined(__aarch64__) ++#if defined(__arm__) || defined(__aarch64__) || defined(__loongarch__) + #ifdef __has_include + #if __has_include() + #include +diff --git a/src/common/cm_utils/cm_memory.h b/src/common/cm_utils/cm_memory.h +index 988b78e..d6494fb 100644 +--- a/src/common/cm_utils/cm_memory.h ++++ b/src/common/cm_utils/cm_memory.h +@@ -56,6 +56,9 @@ extern "C" { + __asm__ volatile("dmb ish" :: \ + : "memory"); \ + } ++#elif defined(__loongarch__) ++#define CM_MFENCE \ ++ {} + #else + #define CM_MFENCE \ + { \ +-- +2.40.1 + diff --git a/opengauss-dcf.spec b/opengauss-dcf.spec index 3bbaebe..aeda247 100644 --- a/opengauss-dcf.spec +++ b/opengauss-dcf.spec @@ -1,6 +1,6 @@ Name: DCF Version: 1.0.0 -Release: 4 +Release: 5 Summary: A distributed consensus framework library License: MulanPSL-2.0 URL: https://gitee.com/opengauss/DCF @@ -8,6 +8,7 @@ Source0: %{name}-%{version}.tar.gz Patch1: 01-boundcheck.patch Patch2: DCF-1.0.0-sw.patch +Patch3: 0001-add-loongarch64-support.patch BuildRequires: cmake gcc gcc-c++ lz4-devel openssl-devel zstd-devel libboundscheck cjson-devel @@ -22,6 +23,9 @@ DCF is A distributed consensus framework library for openGauss %ifarch sw_64 %patch2 -p1 %endif +%ifarch loongarch64 +%patch3 -p1 +%endif %build cmake -DCMAKE_BUILD_TYPE=Release -DUSE32BIT=OFF -DTEST=OFF -DENABLE_EXPORT_API=OFF CMakeLists.txt @@ -30,17 +34,9 @@ cmake -DCMAKE_BUILD_TYPE=Release -DUSE32BIT=OFF -DTEST=OFF -DENABLE_EXPORT_API=O %install mkdir -p %{buildroot}/%{_prefix}/include -%ifarch sw_64 -mkdir -p %{buildroot}/%{_prefix}/lib -%else -mkdir -p %{buildroot}/%{_prefix}/lib64 -%endif +mkdir -p %{buildroot}/%{_libdir} cp src/interface/dcf_interface.h %{buildroot}/%{_prefix}/include -%ifarch sw_64 -cp output/lib/libdcf.* %{buildroot}/%{_prefix}/lib -%else -cp output/lib/libdcf.* %{buildroot}/%{_prefix}/lib64 -%endif +cp output/lib/libdcf.* %{buildroot}/%{_libdir} %post @@ -49,13 +45,12 @@ cp output/lib/libdcf.* %{buildroot}/%{_prefix}/lib64 %files %defattr (-,root,root) %{_prefix}/include/dcf_interface.h -%ifarch sw_64 -%{_prefix}/lib/libdcf.so -%else -%{_prefix}/lib64/libdcf.so -%endif +%{_libdir}/libdcf.so %changelog +* Mon Aug 7 2023 panchenbo - 1.0.0-5 +- add support for loongarch64 + * Mon Oct 24 2022 wuzx - 1.0.0-4 - change lib64 to lib when in sw64 architecture -- Gitee