已开启
提供pljava在riscv64平台上的适配 #314
提供pljava在riscv64平台上的适配 #314
已开启
MengMengDeXiaoJi创建于 2025年5月8日
3 个文件变更+183-0
@@ -0,0 +1,81 @@
1+From 3ff7e3a407e92bede80c630d147b9dad799b6518 Mon Sep 17 00:00:00 2001
2+From: huangji <huangji@iscas.ac.cn>
3+Date: Mon, 20 Jan 2025 02:10:11 +0000
4+Subject: [PATCH] add riscv64 suppoprt
5+ 
6+Signed-off-by: huangji <huangji@iscas.ac.cn>
7+---
8+ kernal/src/include/storage/lock/s_lock.h | 57 ++++++++++++++++++++++++
9+ 1 file changed, 57 insertions(+)
10+ 
11+diff --git a/kernal/src/include/storage/lock/s_lock.h b/kernal/src/include/storage/lock/s_lock.h
12+index 6a64c9d..fc26b6e 100644
13+--- a/kernal/src/include/storage/lock/s_lock.h
14++++ b/kernal/src/include/storage/lock/s_lock.h
15+@@ -380,6 +380,63 @@ static __inline__ int tas(volatile slock_t* lock)
16+ #endif /* HAVE_GCC_INT_ATOMICS */
17+ #endif /* __arm__ */
18+
19++#if defined(__riscv)
20++
21++#ifdef ENABLE_THREAD_CHECK
22++extern "C" {
23++ void AnnotateHappensBefore(const char *f, int l, uintptr_t addr);
24++ void AnnotateHappensAfter(const char *f, int l, uintptr_t addr);
25++}
26++#define TsAnnotateHappensBefore(addr) AnnotateHappensBefore(__FILE__, __LINE__, (uintptr_t)addr)
27++#define TsAnnotateHappensAfter(addr) AnnotateHappensAfter(__FILE__, __LINE__, (uintptr_t)addr)
28++#else
29++#define TsAnnotateHappensBefore(addr)
30++#define TsAnnotateHappensAfter(addr)
31++#endif /* endif ENABLE_THREAD_CHECK */
32++
33++#define HAS_TEST_AND_SET
34++
35++#define TAS(lock) tas(lock)
36++
37++#ifdef HAVE_GCC_INT_ATOMICS
38++
39++typedef int slock_t;
40++
41++static __inline__ int
42++tas(volatile slock_t *lock)
43++{
44++ int ret = __sync_lock_test_and_set(lock, 1);
45++ TsAnnotateHappensAfter(lock);
46++ return ret;
47++}
48++
49++#define S_UNLOCK(lock) do { \
50++ TsAnnotateHappensBefore(lock); \
51++ __sync_lock_release(lock); \
52++} while(0)
53++
54++#else /* !HAVE_GCC_INT_ATOMICS */
55++
56++typedef unsigned int slock_t;
57++
58++static __inline__ int tas(volatile slock_t* lock)
59++{
60++ register slock_t _res = 1;
61++
62++ __asm__ volatile(
63++ "again: amoswap.w.aq %0, %0, (%1)\n"
64++ " bnez %0, again\n"
65++ " amoswap.w.rl x0, x0, (%1)\n"
66++ : "+r"(_res), "+r"(lock)
67++ :
68++ : "memory"
69++ );
70++ return (int)_res;
71++}
72++
73++#endif /* HAVE_GCC_INT_ATOMICS */
74++#endif /* __riscv */
75++
76+ /* S/390 and S/390x Linux (32- and 64-bit zSeries) */
77+ #if defined(__s390__) || defined(__s390x__)
78+ #define HAS_TEST_AND_SET
79+--
80+2.33.0
81+ 
@@ -26,6 +26,8 @@ function main()
26 cd $SOURCE_CODE_PATH26 cd $SOURCE_CODE_PATH
27 patch -p1 < ../pljava.patch -N 2>&127 patch -p1 < ../pljava.patch -N 2>&1
28 patch -p1 < ../to_openjdk.patch 2>&128 patch -p1 < ../to_openjdk.patch 2>&1
29+ patch -p1 < ../add-riscv64-support.patch 2>&1
30+ patch -p1 < ../fix-build-error.patch 2>&1
29 cd ..31 cd ..
30 case "${BUILD_OPTION}" in32 case "${BUILD_OPTION}" in
31 build)33 build)
@@ -0,0 +1,100 @@
1+From d30f7c16c10c02dce1bc53ea35ce8a15c46a16aa Mon Sep 17 00:00:00 2001
2+From: huangji <huangji@iscas.ac.cn>
3+Date: Thu, 27 Mar 2025 14:34:49 +0800
4+Subject: [PATCH] fix build error
5+ 
6+Signed-off-by: huangji <huangji@iscas.ac.cn>
7+---
8+ kernal/src/Makefile.global | 30 +++++++++++++++---------------
9+ 1 file changed, 15 insertions(+), 15 deletions(-)
10+ 
11+diff --git a/kernal/src/Makefile.global b/kernal/src/Makefile.global
12+index 3549060..8e92851 100644
13+--- a/kernal/src/Makefile.global
14++++ b/kernal/src/Makefile.global
15+@@ -53,7 +53,7 @@ endif
16+ vpathsearch = `for f in $(addsuffix /$(1),$(subst :, ,. $(VPATH))); do test -r $$f && echo $$f && break; done`
17+
18+ # Saved arguments from configure
19+-configure_args = '--gcc-version=8.2.0' '--prefix=/data4/wangwei/GaussDBKernel-server/install' 'CFLAGS=-O0' '--enable-debug' '--enable-cassert' '--enable-thread-safety' '--without-zlib' '--enable-multiple-nodes' '-3rd=/data4/wangwei/GaussDBKernel-third_party_binarylibs' 'CC=g++'
20++configure_args = '--gcc-version=8.2.0' '--prefix=/data4/wangwei/GaussDBKernel-server/install' 'CFLAGS=-O2' '--enable-debug' '--enable-cassert' '--enable-thread-safety' '--without-zlib' '--enable-multiple-nodes' '-3rd=/data4/wangwei/GaussDBKernel-third_party_binarylibs' 'CC=g++'
21+
22+
23+ ##########################################################################
24+@@ -687,22 +687,22 @@ LIBCURL_LIB_PATH = $(LIBCURL_HOME)/lib
25+ ############################################################################
26+ # Compilers
27+ CPP = g++ -E
28+-CPPFLAGS = -D_GNU_SOURCE
29++CPPFLAGS = -D_GNU_SOURCE -D_FORTIFY_SOURCE=2
30+ #CPPFLAGS = -D_GNU_SOURCE -DHAVE_LIBREADLINE=1 -DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE_HISTORY_H=1 -DHAVE_RL_COMPLETION_APPEND_CHARACTER=1 -DHAVE_RL_COMPLETION_MATCHES=1 -DHAVE_RL_FILENAME_COMPLETION_FUNCTION=1 -DHAVE_HISTORY_TRUNCATE_FILE=1
31+ ifeq ($(enable_llt), yes)
32+-CPPFLAGS = -D_GNU_SOURCE -DHAVE_LIBREADLINE=1 -DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE_HISTORY_H=1 -DHAVE_RL_COMPLETION_APPEND_CHARACTER=1 -DHAVE_RL_COMPLETION_MATCHES=1 -DHAVE_RL_FILENAME_COMPLETION_FUNCTION=1 -DHAVE_HISTORY_TRUNCATE_FILE=1 -Wl,-R$(LIBEDIT_LIB_PATH) -fPIC
33++CPPFLAGS = -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -DHAVE_LIBREADLINE=1 -DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE_HISTORY_H=1 -DHAVE_RL_COMPLETION_APPEND_CHARACTER=1 -DHAVE_RL_COMPLETION_MATCHES=1 -DHAVE_RL_FILENAME_COMPLETION_FUNCTION=1 -DHAVE_HISTORY_TRUNCATE_FILE=1 -Wl,-R$(LIBEDIT_LIB_PATH) -fPIC
34+ endif
35+
36+ #CPPFLAGS = -D_GNU_SOURCE
37+
38+ ifeq ($(enable_ut), yes)
39+- CPPFLAGS = -D_GNU_SOURCE -fPIC
40++ CPPFLAGS = -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
41+ else
42+ ifeq ($(POSTGIS_PGSQL_VERSION), 92)
43+- CPPFLAGS = -D_GNU_SOURCE -fPIC
44++ CPPFLAGS = -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
45+ else
46+ ifeq ($(enable_debug), no)
47+- CPPFLAGS = -D_GNU_SOURCE -fPIE
48++ CPPFLAGS = -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -fPIE
49+ endif
50+ endif
51+ endif
52+@@ -740,36 +740,36 @@ SUN_STUDIO_CC = no
53+ CFLAGS_SSE42 = -msse4.2
54+
55+ ifeq ($(enable_llt), yes)
56+- CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O0 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror $(PTHREAD_CFLAGS) -Wl,-R$(LIBEDIT_LIB_PATH) -fPIC
57++ CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O2 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror $(PTHREAD_CFLAGS) -Wl,-R$(LIBEDIT_LIB_PATH) -fPIC
58+ else
59+ ifeq ($(POSTGIS_PGSQL_VERSION), 92)
60+- CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O0 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror $(PTHREAD_CFLAGS) -fPIC
61++ CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O2 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror $(PTHREAD_CFLAGS) -fPIC
62+ else
63+ ifeq ($(enable_debug), no)
64+- CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O0 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror $(PTHREAD_CFLAGS) -fPIE
65++ CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O2 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror $(PTHREAD_CFLAGS) -fPIE
66+ else
67+- CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O0 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror $(PTHREAD_CFLAGS)
68++ CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O2 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror $(PTHREAD_CFLAGS)
69+ endif
70+ endif
71+ endif
72+
73+ ifeq ($(enable_llt), no)
74+ ifeq ($(enable_ut), yes)
75+- CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O0 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror -fPIC
76++ CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O2 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror -fPIC
77+ else
78+ ifeq ($(POSTGIS_PGSQL_VERSION), 92)
79+- CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O0 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror -fPIC
80++ CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O2 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror -fPIC
81+ else
82+ ifeq ($(enable_debug), no)
83+- CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O0 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror -fPIE
84++ CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O2 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror -fPIE
85+ else
86+- CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O0 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror
87++ CFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O2 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror
88+ endif
89+ endif
90+ endif
91+ endif
92+
93+-CXXFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O0 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror
94++CXXFLAGS = -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -fsigned-char -DSTREAMPLAN -DPGXC -O2 -Wall -Wpointer-arith -Wno-write-strings -fnon-call-exceptions -fno-common -freg-struct-return -pipe -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -DENABLE_GSTRACE -fno-aggressive-loop-optimizations -Wno-attributes -fno-omit-frame-pointer -fno-expensive-optimizations -Wno-unused-but-set-variable -Werror
95+ ifeq ($(enable_memory_check), yes)
96+ CXXFLAGS += -fsanitize=address -fsanitize=leak -fno-omit-frame-pointer
97+ else
98+--
99+2.33.0
100+