Init riscv64 support

This commit is contained in:
misaka00251 2023-08-24 16:36:30 +08:00
parent 19a7fcd0d6
commit 9decc87180
No known key found for this signature in database
GPG Key ID: 1F50F0319B8BAFCB
2 changed files with 157 additions and 3 deletions

118
add-riscv64-support.patch Normal file
View File

@ -0,0 +1,118 @@
diff --git a/common/autoconf/build-aux/autoconf-config.guess b/common/autoconf/build-aux/autoconf-config.guess
index 15ee4389..c7355c33 100644
--- a/common/autoconf/build-aux/autoconf-config.guess
+++ b/common/autoconf/build-aux/autoconf-config.guess
@@ -1000,6 +1000,9 @@ EOF
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
exit ;;
+ riscv64:Linux:*:*)
+ echo riscv64-unknown-linux-gnu
+ exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
exit ;;
diff --git a/common/autoconf/build-aux/autoconf-config.sub b/common/autoconf/build-aux/autoconf-config.sub
index 1aab2b30..662b002a 100644
--- a/common/autoconf/build-aux/autoconf-config.sub
+++ b/common/autoconf/build-aux/autoconf-config.sub
@@ -302,6 +302,7 @@ case $basic_machine in
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
+ | riscv32 | riscv64 \
| score \
| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
@@ -383,6 +384,7 @@ case $basic_machine in
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
+ | riscv32-* | riscv64-* \
| romp-* | rs6000-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4
index 51df988f..1cce0e4f 100644
--- a/common/autoconf/platform.m4
+++ b/common/autoconf/platform.m4
@@ -96,6 +96,12 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=big
;;
+ riscv64)
+ VAR_CPU=riscv64
+ VAR_CPU_ARCH=riscv
+ VAR_CPU_BITS=64
+ VAR_CPU_ENDIAN=little
+ ;;
*)
AC_MSG_ERROR([unsupported cpu $1])
;;
@@ -381,6 +387,7 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS],
sparc*) ZERO_ARCHDEF=SPARC ;;
x86_64*) ZERO_ARCHDEF=AMD64 ;;
x86) ZERO_ARCHDEF=IA32 ;;
+ riscv*) ZERO_ARCHDEF=RISCV ;;
*) ZERO_ARCHDEF=$(echo "${OPENJDK_TARGET_CPU_LEGACY_LIB}" | tr a-z A-Z)
esac
AC_SUBST(ZERO_ARCHDEF)
diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp
index 2d3880b3..6ec35ec1 100644
--- a/hotspot/src/os/linux/vm/os_linux.cpp
+++ b/hotspot/src/os/linux/vm/os_linux.cpp
@@ -367,7 +367,7 @@ void os::init_system_properties_values() {
// 1: ...
// ...
// 7: The default directories, normally /lib and /usr/lib.
-#if defined(AMD64) || defined(_LP64) && (defined(SPARC) || defined(PPC) || defined(S390))
+#if defined(AMD64) || defined(_LP64) && (defined(SPARC) || defined(PPC) || defined(S390) || defined(RISCV))
#define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib"
#else
#define DEFAULT_LIBPATH "/lib:/usr/lib"
@@ -1953,6 +1953,9 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
#ifndef EM_AARCH64
#define EM_AARCH64 183 /* ARM AARCH64 */
#endif
+ #ifndef EM_RISCV
+ #define EM_RISCV 243 /* RISC-V */
+ #endif
static const arch_t arch_array[]={
{EM_386, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
@@ -1976,6 +1979,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
{EM_PARISC, EM_PARISC, ELFCLASS32, ELFDATA2MSB, (char*)"PARISC"},
{EM_68K, EM_68K, ELFCLASS32, ELFDATA2MSB, (char*)"M68k"},
{EM_AARCH64, EM_AARCH64, ELFCLASS64, ELFDATA2LSB, (char*)"AARCH64"},
+ {EM_RISCV, EM_RISCV, ELFCLASSNONE, ELFDATA2MSB, (char*)"RISCV"},
};
#if (defined IA32)
@@ -2008,9 +2012,11 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
static Elf32_Half running_arch_code=EM_68K;
#elif (defined AARCH64)
static Elf32_Half running_arch_code=EM_AARCH64;
+ #elif (defined RISCV)
+ static Elf32_Half running_arch_code=EM_RISCV;
#else
#error Method os::dll_load requires that one of following is defined:\
- IA32, AMD64, IA64, __sparc, __powerpc__, ARM, S390, ALPHA, MIPS, MIPSEL, PARISC, M68K, AARCH64
+ IA32, AMD64, IA64, __sparc, __powerpc__, ARM, S390, ALPHA, MIPS, MIPSEL, PARISC, M68K, AARCH64, RISCV
#endif
// Identify compatability class for VM's architecture and library's architecture
@@ -2043,10 +2049,12 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
}
#ifndef S390
+#ifndef RISCV
if (lib_arch.elf_class != arch_array[running_arch_index].elf_class) {
::snprintf(diag_msg_buf, diag_msg_max_length-1," (Possible cause: architecture word width mismatch)");
return NULL;
}
+#endif // RISCV
#endif // !S390
if (lib_arch.compat_class != arch_array[running_arch_index].compat_class) {
--
2.17.1

View File

@ -52,6 +52,7 @@
%endif
%global aarch64 aarch64
%global riscv64 riscv64
%global jit_arches x86_64 %{aarch64}
%global sa_arches x86_64 %{aarch64}
%global jfr_arches x86_64 %{aarch64}
@ -115,6 +116,10 @@
%global archinstall aarch64
%global stapinstall arm64
%endif
%ifarch %{riscv64}
%global archinstall riscv64
%global stapinstall %{nil}
%endif
%ifarch %{jit_arches}
%global with_systemtap 1
@ -125,6 +130,9 @@
# New Version-String scheme-style defines
%global majorver 8
%ifnarch riscv64
%global with_openjfx_binding 0
%else
%global with_openjfx_binding 1
%global openjfx_path %{_jvmdir}/openjfx8
# links src directories
@ -140,6 +148,7 @@
%global jfx_sdk_libs javafx-mx.jar packager.jar ant-javafx.jar
%global jfx_sdk_bins javafxpackager javapackager
%global jfx_jre_exts jfxrt.jar
%endif
# Standard JPackage naming and versioning defines.
%global origin openjdk
@ -916,7 +925,7 @@ Provides: java-%{javaver}-%{origin}-accessibility%{?1} = %{epoch}:%{version}-%{r
Name: java-%{javaver}-%{origin}
Version: %{javaver}.%{updatever}.%{buildver}
Release: 2
Release: 3
# java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons
# and this change was brought into RHEL-4. java-1.5.0-ibm packages
# also included the epoch in their virtual provides. This created a
@ -1293,6 +1302,9 @@ Patch539: pr2888-openjdk_should_check_for_system_cacerts_database_eg_etc_pki_jav
#############################################
Patch1000: rh1648249-add_commented_out_nss_cfg_provider_to_java_security.patch
# riscv64 support
Patch2000: add-riscv64-support.patch
#############################################
#
# Dependencies
@ -1826,6 +1838,9 @@ pushd %{top_level_dir_name}
%patch365 -p1
%patch366 -p1
%patch367 -p1
%ifarch riscv64
%patch2000 -p1
%endif
popd
# System library fixes
@ -1893,7 +1908,7 @@ export NUM_PROC=${NUM_PROC:-1}
[ ${NUM_PROC} -gt %{?_smp_ncpus_max} ] && export NUM_PROC=%{?_smp_ncpus_max}
%endif
%ifarch %{aarch64}
%ifarch %{aarch64} riscv64
export ARCH_DATA_MODEL=64
%endif
@ -1905,6 +1920,12 @@ EXTRA_CPP_FLAGS="%ourcppflags -Wno-error"
EXTRA_ASFLAGS="${EXTRA_CFLAGS} -Wa,--generate-missing-build-notes=yes"
export EXTRA_CFLAGS EXTRA_ASFLAGS
%ifarch riscv64
(cd %{top_level_dir_name}/common/autoconf
bash ./autogen.sh
)
%endif
for suffix in %{build_loop} ; do
(if [ "x$suffix" = "x" ] ; then
debugbuild=release
@ -1922,6 +1943,14 @@ pushd %{buildoutputdir -- $suffix}
bash ${top_srcdir_abs_path}/configure \
%ifarch %{jfr_arches}
--enable-jfr \
%else
--disable-jfr \
%endif
%ifarch riscv64
--disable-cds-archive \
%endif
%ifnarch %{jit_arches}
--with-jvm-variants=zero \
%endif
--with-native-debug-symbols=internal \
--with-milestone="fcs" \
@ -1934,7 +1963,11 @@ bash ${top_srcdir_abs_path}/configure \
--with-vendor-vm-bug-url="https://gitee.com/src-openeuler/openjdk-1.8.0/issues/" \
--with-debug-level=$debugbuild \
--enable-unlimited-crypto \
--enable-kae=yes \
%ifarch %{jit_arches}
--enable-kae \
%else
--disable-kae \
%endif
--with-stdc++lib=dynamic \
--with-extra-cflags="$EXTRA_CFLAGS" \
--with-extra-cxxflags="$EXTRA_CPP_FLAGS" \
@ -2449,6 +2482,9 @@ cjc.mainProgram(arg)
%endif
%changelog
* Thu Aug 24 2023 misaka00251 <liuxin@iscas.ac.cn> - 1:1.8.0.382-b05.3
- Init riscv64 support
* Thu Aug 24 2023 kuenking111 <wangkun49@huawei.com> - 1:1.8.0.382-b05.2
- deleted 0053-8146987-Improve-Parallel-GC-Full-GC-by-caching-resul.patch