diff --git a/0001-add-loongarch64-support.patch b/0001-add-loongarch64-support.patch new file mode 100644 index 0000000000000000000000000000000000000000..138ecaf46728df76c0f6475b6a26b85e9c1df844 --- /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/DCF-1.0.0-sw.patch b/DCF-1.0.0-sw.patch new file mode 100755 index 0000000000000000000000000000000000000000..6635efb995fdb212cbce4a30a9a78005df1de6ca --- /dev/null +++ b/DCF-1.0.0-sw.patch @@ -0,0 +1,76 @@ +diff -Nuar DCF-1.0.0.org/CMakeLists.txt DCF-1.0.0.sw/CMakeLists.txt +--- DCF-1.0.0.org/CMakeLists.txt 2022-06-13 11:22:02.120000000 +0000 ++++ DCF-1.0.0.sw/CMakeLists.txt 2022-06-13 11:22:51.510000000 +0000 +@@ -89,7 +89,7 @@ + + add_compile_options(-mtune=cortex-a72 -fsigned-char -g -ggdb3 -march=armv8-a+crc -funwind-tables) + else () +- add_compile_options(-msse4.2 ) ++ add_compile_options( ) + endif () + Add_Definitions(-DWSEC_COMPILE_CAC_OPENSSL -DWSEC_AES_GCM_SUPPORT -DWSEC_USE_OPENSSL_110) + else () +@@ -106,4 +106,4 @@ + OPTION(TEST "option for test module" ON) + if (TEST) + add_subdirectory(test) +-endif() +\ No newline at end of file ++endif() +diff -Nuar DCF-1.0.0.org/src/common/cm_concurrency/cm_spinlock.h DCF-1.0.0.sw/src/common/cm_concurrency/cm_spinlock.h +--- DCF-1.0.0.org/src/common/cm_concurrency/cm_spinlock.h 2022-06-13 11:22:02.090000000 +0000 ++++ DCF-1.0.0.sw/src/common/cm_concurrency/cm_spinlock.h 2022-06-13 16:12:03.530000000 +0000 +@@ -68,6 +68,9 @@ + { \ + __asm__ volatile("nop"); \ + } ++#elif defined(__sw_64__) ++#define fas_cpu_pause() \ ++ {} + #else + #define fas_cpu_pause() \ + { \ +diff -Nuar DCF-1.0.0.org/src/common/cm_concurrency/cm_thread.c DCF-1.0.0.sw/src/common/cm_concurrency/cm_thread.c +--- DCF-1.0.0.org/src/common/cm_concurrency/cm_thread.c 2022-06-13 11:22:02.100000000 +0000 ++++ DCF-1.0.0.sw/src/common/cm_concurrency/cm_thread.c 2022-06-13 16:39:23.220000000 +0000 +@@ -296,6 +296,8 @@ + #define __SYS_GET_SPID 186 + #elif (defined __aarch64__) + #define __SYS_GET_SPID 178 ++#elif (defined __sw_64__) ++#define __SYS_GET_SPID 378 + #endif + #define gettid() syscall(__SYS_GET_SPID) + +diff -Nuar DCF-1.0.0.org/src/common/cm_utils/cm_checksum.h DCF-1.0.0.sw/src/common/cm_utils/cm_checksum.h +--- DCF-1.0.0.org/src/common/cm_utils/cm_checksum.h 2022-06-13 11:22:02.100000000 +0000 ++++ DCF-1.0.0.sw/src/common/cm_utils/cm_checksum.h 2022-06-13 16:33:54.130000000 +0000 +@@ -26,7 +26,7 @@ + + #include "cm_defs.h" + +-#if defined(__arm__) || defined(__aarch64__) ++#if defined(__arm__) || defined(__aarch64__) || defined(__sw_64__) + #ifdef __has_include + #if __has_include() + #include +diff -Nuar DCF-1.0.0.org/src/common/cm_utils/cm_memory.h DCF-1.0.0.sw/src/common/cm_utils/cm_memory.h +--- DCF-1.0.0.org/src/common/cm_utils/cm_memory.h 2022-06-13 11:22:02.100000000 +0000 ++++ DCF-1.0.0.sw/src/common/cm_utils/cm_memory.h 2022-06-13 16:10:02.430000000 +0000 +@@ -50,12 +50,15 @@ + __asm {mfence } \ + } + #endif +-#elif defined(__arm__) || defined(__aarch64__) ++#elif defined(__arm__) || defined(__aarch64__) + #define CM_MFENCE \ + { \ + __asm__ volatile("dmb ish" :: \ + : "memory"); \ + } ++#elif defined(__sw_64__) ++#define CM_MFENCE \ ++ {} + #else + #define CM_MFENCE \ + { \ diff --git a/DCF-1.0.0.tar.gz b/DCF-1.0.0.tar.gz index 22052d6194293da55e5f3e038f95d032bc1b85ee..103f62b65f4e7f409f7f774d2d1a689fe136a26c 100644 Binary files a/DCF-1.0.0.tar.gz and b/DCF-1.0.0.tar.gz differ diff --git a/opengauss-dcf.spec b/opengauss-dcf.spec index 37124c63194ee7e05c18f0596fde753d3ff46f3e..aeda24746c6824e9d9a35958c2df85934bcc588a 100644 --- a/opengauss-dcf.spec +++ b/opengauss-dcf.spec @@ -1,12 +1,14 @@ Name: DCF Version: 1.0.0 -Release: 1 +Release: 5 Summary: A distributed consensus framework library License: MulanPSL-2.0 URL: https://gitee.com/opengauss/DCF 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 @@ -18,6 +20,12 @@ DCF is A distributed consensus framework library for openGauss %prep %setup -q %patch1 -p1 +%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 @@ -26,9 +34,9 @@ cmake -DCMAKE_BUILD_TYPE=Release -DUSE32BIT=OFF -DTEST=OFF -DENABLE_EXPORT_API=O %install mkdir -p %{buildroot}/%{_prefix}/include -mkdir -p %{buildroot}/%{_prefix}/lib +mkdir -p %{buildroot}/%{_libdir} cp src/interface/dcf_interface.h %{buildroot}/%{_prefix}/include -cp output/lib/libdcf.* %{buildroot}/%{_prefix}/lib +cp output/lib/libdcf.* %{buildroot}/%{_libdir} %post @@ -37,8 +45,20 @@ cp output/lib/libdcf.* %{buildroot}/%{_prefix}/lib %files %defattr (-,root,root) %{_prefix}/include/dcf_interface.h -%{_prefix}/lib/libdcf.so +%{_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 + +* Thu Jul 28 2022 wuzx - 1.0.0-3 +- add sw64 patch + +* Thu Feb 10 2022 zhangxubo - 1.0.0-2 +- #I4T3R3 move library file to /usr/lib64 path. + * Wed Dec 1 2021 zhangxubo - 1.0.0-1 - Package init