Add support for RISC-V (riscv64)

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
This commit is contained in:
David Abdurachmanov 2021-05-07 10:51:12 +03:00
parent 9a65c1deb8
commit dd83fd68ad
Signed by: davidlt
GPG Key ID: 8B7F1DA0E2C9FDBB
4 changed files with 3663 additions and 1 deletions

1704
config.guess vendored Normal file

File diff suppressed because it is too large Load Diff

1864
config.sub vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,71 @@
diff --git a/openjdk/make/autoconf/platform.m4 b/openjdk/make/autoconf/platform.m4
index e06c11af0..e1c55bb1b 100644
--- a/openjdk/make/autoconf/platform.m4
+++ b/openjdk/make/autoconf/platform.m4
@@ -150,6 +150,18 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
VAR_CPU_BITS=64
VAR_CPU_ENDIAN=big
;;
+ riscv32)
+ VAR_CPU=riscv32
+ VAR_CPU_ARCH=riscv
+ VAR_CPU_BITS=32
+ VAR_CPU_ENDIAN=little
+ ;;
+ riscv64)
+ VAR_CPU=riscv64
+ VAR_CPU_ARCH=riscv
+ VAR_CPU_BITS=64
+ VAR_CPU_ENDIAN=little
+ ;;
*)
AC_MSG_ERROR([unsupported cpu $1])
;;
diff --git a/openjdk/src/hotspot/os/linux/os_linux.cpp b/openjdk/src/hotspot/os/linux/os_linux.cpp
index 8496e3db1..a154fd3e3 100644
--- a/openjdk/src/hotspot/os/linux/os_linux.cpp
+++ b/openjdk/src/hotspot/os/linux/os_linux.cpp
@@ -1728,6 +1728,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"},
@@ -1753,6 +1756,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*)"RISC-V"},
};
#if (defined IA32)
@@ -1787,9 +1791,11 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
static Elf32_Half running_arch_code=EM_68K;
#elif (defined SH)
static Elf32_Half running_arch_code=EM_SH;
+#elif (defined __riscv)
+ static Elf32_Half running_arch_code=EM_RISCV;
#else
#error Method os::dll_load requires that one of following is defined:\
- AARCH64, ALPHA, ARM, AMD64, IA32, IA64, M68K, MIPS, MIPSEL, PARISC, __powerpc__, __powerpc64__, S390, SH, __sparc
+ AARCH64, ALPHA, ARM, AMD64, IA32, IA64, M68K, MIPS, MIPSEL, PARISC, __powerpc__, __powerpc64__, S390, SH, __sparc, __riscv
#endif
// Identify compatability class for VM's architecture and library's architecture
@@ -1822,10 +1828,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) {

View File

@ -272,6 +272,10 @@
%global archinstall aarch64
%global stapinstall arm64
%endif
%ifarch riscv64
%global archinstall riscv64
%global stapinstall %{nil}
%endif
# 32 bit sparc, optimized for v9
%ifarch sparcv9
%global archinstall sparc
@ -1189,6 +1193,10 @@ Source15: TestSecurityProperties.java
# Ensure vendor settings are correct
Source16: CheckVendor.java
# New versions of config files with RISC-V (riscv64) support.
Source100: config.guess
Source101: config.sub
############################################
#
# RPM/distribution specific patches
@ -1230,6 +1238,9 @@ Patch4: pr3694-rh1340845-support_fedora_rhel_system_crypto_policy.patch
# PR3695: Allow use of system crypto policy to be disabled by the user
Patch7: pr3695-toggle_system_crypto_policy.patch
# RISC-V (riscv64) support
Patch30: java-11-openjdk-riscv64.patch
#############################################
#
# Patches appearing in 11.0.10
@ -1584,6 +1595,12 @@ if [ $prioritylength -ne 8 ] ; then
exit 14
fi
%ifarch riscv64
# Update config.{guess,sub} with RISC-V (riscv64) support
cp %{SOURCE100} openjdk/make/autoconf/build-aux/
cp %{SOURCE101} openjdk/make/autoconf/build-aux/
%endif
# OpenJDK patches
# Remove libraries that are linked by both static and dynamic builds
sh %{SOURCE12} %{top_level_dir_name}
@ -1595,6 +1612,9 @@ pushd %{top_level_dir_name}
%patch3 -p1
%patch4 -p1
%patch7 -p1
%ifarch riscv64
%patch30 -p2
%endif
popd # openjdk
%patch1000
@ -1661,7 +1681,7 @@ export NUM_PROC=${NUM_PROC:-1}
[ ${NUM_PROC} -gt %{?_smp_ncpus_max} ] && export NUM_PROC=%{?_smp_ncpus_max}
%endif
%ifarch s390x sparc64 alpha %{power64} %{aarch64}
%ifarch s390x sparc64 alpha %{power64} %{aarch64} riscv64
export ARCH_DATA_MODEL=64
%endif
%ifarch alpha
@ -2291,6 +2311,9 @@ require "copy_jdk_configs.lua"
%endif
%changelog
* Fri May 07 2021 David Abdurachmanov <david.abdurachmanov@gmail.com> - 1:11.0.11.0.9-1.0.riscv64
- Add support for RISC-V (riscv64)
* Fri Apr 29 2021 Jiri Vanek <jvanek@redhat.com> - 1:11.0.11.0.9-1
- adapted to debug handling in newer cjc
- The rest of the "rpm 4.17" patch must NOT be backported, as on rpm 4.16 and down, it would casue double execution