From 575fbe0e04b9082cae233f60ee264eb72b76bf54 Mon Sep 17 00:00:00 2001 From: huangji Date: Mon, 7 Apr 2025 15:56:17 +0800 Subject: [PATCH 1/2] add pljava support for riscv64 Signed-off-by: huangji --- dependency/pljava/add-riscv64-support.patch | 81 +++++++++++++++++++++ dependency/pljava/build.sh | 1 + 2 files changed, 82 insertions(+) create mode 100644 dependency/pljava/add-riscv64-support.patch diff --git a/dependency/pljava/add-riscv64-support.patch b/dependency/pljava/add-riscv64-support.patch new file mode 100644 index 000000000..876a6ae2a --- /dev/null +++ b/dependency/pljava/add-riscv64-support.patch @@ -0,0 +1,81 @@ +From 3ff7e3a407e92bede80c630d147b9dad799b6518 Mon Sep 17 00:00:00 2001 +From: huangji +Date: Mon, 20 Jan 2025 02:10:11 +0000 +Subject: [PATCH] add riscv64 suppoprt + +Signed-off-by: huangji +--- + kernal/src/include/storage/lock/s_lock.h | 57 ++++++++++++++++++++++++ + 1 file changed, 57 insertions(+) + +diff --git a/kernal/src/include/storage/lock/s_lock.h b/kernal/src/include/storage/lock/s_lock.h +index 6a64c9d..fc26b6e 100644 +--- a/kernal/src/include/storage/lock/s_lock.h ++++ b/kernal/src/include/storage/lock/s_lock.h +@@ -380,6 +380,63 @@ static __inline__ int tas(volatile slock_t* lock) + #endif /* HAVE_GCC_INT_ATOMICS */ + #endif /* __arm__ */ + ++#if defined(__riscv) ++ ++#ifdef ENABLE_THREAD_CHECK ++extern "C" { ++ void AnnotateHappensBefore(const char *f, int l, uintptr_t addr); ++ void AnnotateHappensAfter(const char *f, int l, uintptr_t addr); ++} ++#define TsAnnotateHappensBefore(addr) AnnotateHappensBefore(__FILE__, __LINE__, (uintptr_t)addr) ++#define TsAnnotateHappensAfter(addr) AnnotateHappensAfter(__FILE__, __LINE__, (uintptr_t)addr) ++#else ++#define TsAnnotateHappensBefore(addr) ++#define TsAnnotateHappensAfter(addr) ++#endif /* endif ENABLE_THREAD_CHECK */ ++ ++#define HAS_TEST_AND_SET ++ ++#define TAS(lock) tas(lock) ++ ++#ifdef HAVE_GCC_INT_ATOMICS ++ ++typedef int slock_t; ++ ++static __inline__ int ++tas(volatile slock_t *lock) ++{ ++ int ret = __sync_lock_test_and_set(lock, 1); ++ TsAnnotateHappensAfter(lock); ++ return ret; ++} ++ ++#define S_UNLOCK(lock) do { \ ++ TsAnnotateHappensBefore(lock); \ ++ __sync_lock_release(lock); \ ++} while(0) ++ ++#else /* !HAVE_GCC_INT_ATOMICS */ ++ ++typedef unsigned int slock_t; ++ ++static __inline__ int tas(volatile slock_t* lock) ++{ ++ register slock_t _res = 1; ++ ++ __asm__ volatile( ++ "again: amoswap.w.aq %0, %0, (%1)\n" ++ " bnez %0, again\n" ++ " amoswap.w.rl x0, x0, (%1)\n" ++ : "+r"(_res), "+r"(lock) ++ : ++ : "memory" ++ ); ++ return (int)_res; ++} ++ ++#endif /* HAVE_GCC_INT_ATOMICS */ ++#endif /* __riscv */ ++ + /* S/390 and S/390x Linux (32- and 64-bit zSeries) */ + #if defined(__s390__) || defined(__s390x__) + #define HAS_TEST_AND_SET +-- +2.33.0 + diff --git a/dependency/pljava/build.sh b/dependency/pljava/build.sh index ae12c3726..5b2598fda 100644 --- a/dependency/pljava/build.sh +++ b/dependency/pljava/build.sh @@ -26,6 +26,7 @@ function main() cd $SOURCE_CODE_PATH patch -p1 < ../pljava.patch -N 2>&1 patch -p1 < ../to_openjdk.patch 2>&1 + patch -p1 < ../add-riscv64-support.patch 2>&1 cd .. case "${BUILD_OPTION}" in build) -- Gitee From f415ad1323546c9162fe59c97ac03518d2cd6baf Mon Sep 17 00:00:00 2001 From: huangji Date: Mon, 7 Apr 2025 17:00:39 +0800 Subject: [PATCH 2/2] fix gcc build error on pljava Signed-off-by: huangji --- dependency/pljava/build.sh | 1 + dependency/pljava/fix-build-error.patch | 100 ++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 dependency/pljava/fix-build-error.patch diff --git a/dependency/pljava/build.sh b/dependency/pljava/build.sh index 5b2598fda..277de1a5b 100644 --- a/dependency/pljava/build.sh +++ b/dependency/pljava/build.sh @@ -27,6 +27,7 @@ function main() patch -p1 < ../pljava.patch -N 2>&1 patch -p1 < ../to_openjdk.patch 2>&1 patch -p1 < ../add-riscv64-support.patch 2>&1 + patch -p1 < ../fix-build-error.patch 2>&1 cd .. case "${BUILD_OPTION}" in build) diff --git a/dependency/pljava/fix-build-error.patch b/dependency/pljava/fix-build-error.patch new file mode 100644 index 000000000..535c90989 --- /dev/null +++ b/dependency/pljava/fix-build-error.patch @@ -0,0 +1,100 @@ +From d30f7c16c10c02dce1bc53ea35ce8a15c46a16aa Mon Sep 17 00:00:00 2001 +From: huangji +Date: Thu, 27 Mar 2025 14:34:49 +0800 +Subject: [PATCH] fix build error + +Signed-off-by: huangji +--- + kernal/src/Makefile.global | 30 +++++++++++++++--------------- + 1 file changed, 15 insertions(+), 15 deletions(-) + +diff --git a/kernal/src/Makefile.global b/kernal/src/Makefile.global +index 3549060..8e92851 100644 +--- a/kernal/src/Makefile.global ++++ b/kernal/src/Makefile.global +@@ -53,7 +53,7 @@ endif + vpathsearch = `for f in $(addsuffix /$(1),$(subst :, ,. $(VPATH))); do test -r $$f && echo $$f && break; done` + + # Saved arguments from configure +-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++' ++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++' + + + ########################################################################## +@@ -687,22 +687,22 @@ LIBCURL_LIB_PATH = $(LIBCURL_HOME)/lib + ############################################################################ + # Compilers + CPP = g++ -E +-CPPFLAGS = -D_GNU_SOURCE ++CPPFLAGS = -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 + #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 + ifeq ($(enable_llt), yes) +-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 ++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 + endif + + #CPPFLAGS = -D_GNU_SOURCE + + ifeq ($(enable_ut), yes) +- CPPFLAGS = -D_GNU_SOURCE -fPIC ++ CPPFLAGS = -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -fPIC + else + ifeq ($(POSTGIS_PGSQL_VERSION), 92) +- CPPFLAGS = -D_GNU_SOURCE -fPIC ++ CPPFLAGS = -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -fPIC + else + ifeq ($(enable_debug), no) +- CPPFLAGS = -D_GNU_SOURCE -fPIE ++ CPPFLAGS = -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -fPIE + endif + endif + endif +@@ -740,36 +740,36 @@ SUN_STUDIO_CC = no + CFLAGS_SSE42 = -msse4.2 + + ifeq ($(enable_llt), yes) +- 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 ++ 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 + else + ifeq ($(POSTGIS_PGSQL_VERSION), 92) +- 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 ++ 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 + else + ifeq ($(enable_debug), no) +- 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 ++ 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 + else +- 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) ++ 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) + endif + endif + endif + + ifeq ($(enable_llt), no) + ifeq ($(enable_ut), yes) +- 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 ++ 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 + else + ifeq ($(POSTGIS_PGSQL_VERSION), 92) +- 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 ++ 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 + else + ifeq ($(enable_debug), no) +- 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 ++ 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 + else +- 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 ++ 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 + endif + endif + endif + endif + +-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 ++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 + ifeq ($(enable_memory_check), yes) + CXXFLAGS += -fsanitize=address -fsanitize=leak -fno-omit-frame-pointer + else +-- +2.33.0 + -- Gitee