From 97a68acd9d2466f3f67e97adae032a95d4682221 Mon Sep 17 00:00:00 2001 From: misaka00251 Date: Fri, 6 May 2022 16:53:46 +0800 Subject: [PATCH 1/2] Fix RISC-V support & merge 22.03-LTS branch --- add-riscv-support.patch | 130 ++++++++++++++++++++++++++++++++++++++++ openjdk-1.8.0.spec | 60 +++++++++++++++++-- 2 files changed, 186 insertions(+), 4 deletions(-) create mode 100644 add-riscv-support.patch diff --git a/add-riscv-support.patch b/add-riscv-support.patch new file mode 100644 index 0000000..24bb927 --- /dev/null +++ b/add-riscv-support.patch @@ -0,0 +1,130 @@ +From ac34811e9819fafe28eab7ca7380fcb8808cdc3b Mon Sep 17 00:00:00 2001 +From: Wang Junqiang +Date: Wed, 23 Feb 2022 10:21:38 +0800 +Subject: [PATCH] add riscv64 support + +--- + common/autoconf/build-aux/autoconf-config.guess | 3 +++ + common/autoconf/build-aux/autoconf-config.sub | 2 ++ + common/autoconf/platform.m4 | 7 +++++++ + hotspot/src/os/linux/vm/os_linux.cpp | 12 ++++++++++-- + 4 files changed, 22 insertions(+), 2 deletions(-) + +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 diff --git a/openjdk-1.8.0.spec b/openjdk-1.8.0.spec index 738997d..7bfa316 100644 --- a/openjdk-1.8.0.spec +++ b/openjdk-1.8.0.spec @@ -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} @@ -116,6 +117,17 @@ %global stapinstall arm64 %endif +# Need to support noarch for srpm build +%ifarch noarch +%global archinstall %{nil} +%global stapinstall %{nil} +%endif + +%ifarch %{riscv64} +%global archinstall riscv64 +%global stapinstall %{nil} +%endif + %ifarch %{jit_arches} %global with_systemtap 1 %else @@ -125,6 +137,7 @@ # New Version-String scheme-style defines %global majorver 8 +%ifarch %{ix86} x86_64 %global with_openjfx_binding 1 %global openjfx_path %{_jvmdir}/openjfx8 # links src directories @@ -140,6 +153,9 @@ %global jfx_sdk_libs javafx-mx.jar packager.jar ant-javafx.jar %global jfx_sdk_bins javafxpackager javapackager %global jfx_jre_exts jfxrt.jar +%else +%global with_openjfx_binding 0 +%endif # Standard JPackage naming and versioning defines. %global origin openjdk @@ -916,7 +932,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 @@ -1183,6 +1199,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 +# RISC-V support +Patch2000: add-riscv-support.patch + ############################################# # # Dependencies @@ -1614,6 +1633,9 @@ pushd %{top_level_dir_name} %patch242 -p1 %patch243 -p1 %patch244 -p1 +%ifarch riscv64 +%patch2000 -p1 +%endif popd # System library fixes @@ -1681,7 +1703,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 @@ -1693,6 +1715,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 @@ -1710,6 +1738,11 @@ pushd %{buildoutputdir -- $suffix} bash ${top_srcdir_abs_path}/configure \ %ifarch %{jfr_arches} --enable-jfr \ +%else + --disable-jfr \ +%endif +%ifnarch %{jit_arches} + --with-jvm-variants=zero \ %endif --with-native-debug-symbols=internal \ --with-milestone="fcs" \ @@ -1723,7 +1756,11 @@ bash ${top_srcdir_abs_path}/configure \ --with-debug-level=$debugbuild \ --enable-unlimited-crypto \ --with-zlib=system \ +%ifnarch %{jit_arches} --enable-kae=yes \ +%else + --disable-kae=yes \ +%endif --with-stdc++lib=dynamic \ --with-extra-cflags="$EXTRA_CFLAGS" \ --with-extra-cxxflags="$EXTRA_CPP_FLAGS" \ @@ -1732,8 +1769,10 @@ bash ${top_srcdir_abs_path}/configure \ --with-num-cores="$NUM_PROC" \ --with-boot-jdk-jvmargs=-XX:-UsePerfData +%ifnarch riscv64 cat spec.gmk cat hotspot-spec.gmk +%endif # Debug builds don't need same targets as release for # build speed-up @@ -1838,6 +1877,7 @@ do fi done +%ifnarch riscv64 # Make sure gdb can do a backtrace based on line numbers on libjvm.so # javaCalls.cpp:58 should map to: # http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/file/ff3b27e6bcc2/src/share/vm/runtime/javaCalls.cpp#l58 @@ -1854,6 +1894,7 @@ end run -version EOF grep 'JavaCallWrapper::JavaCallWrapper' gdb.out +%endif # Check src.zip has all sources. See RHBZ#1130490 jar -tf $JAVA_HOME/src.zip | grep 'sun.misc.Unsafe' @@ -2064,7 +2105,13 @@ done -- whether copy-jdk-configs is installed or not. If so, then configs are copied -- (copy_jdk_configs from %%{_libexecdir} used) or not copied at all local posix = require "posix" -local debug = false + +if (os.getenv("debug") == "true") then + debug = true; + print("cjc: in spec debug is on") +else + debug = false; +end SOURCE1 = "%{rpm_state_dir}/copy_jdk_configs.lua" SOURCE2 = "%{_libexecdir}/copy_jdk_configs.lua" @@ -2093,8 +2140,10 @@ else end end -- run content of included file with fake args +arg = nil +cjc = require "copy_jdk_configs.lua" arg = {"--currentjvm", "%{uniquesuffix %{nil}}", "--jvmdir", "%{_jvmdir %{nil}}", "--origname", "%{name}", "--origjavaver", "%{javaver}", "--arch", "%{_arch}", "--temp", "%{rpm_state_dir}/%{name}.%{_arch}"} -require "copy_jdk_configs.lua" +cjc.mainProgram(arg) %post %{post_script %{nil}} @@ -2231,6 +2280,9 @@ require "copy_jdk_configs.lua" %endif %changelog +* Fri May 06 2022 misaka00251 - 1:1.8.0.332-b09.3 +- Fix RISC-V support & merge 22.03-LTS branch + * Thu Apr 28 2022 kuenking111 - 1:1.8.0.332-b09.2 - add fix_X509TrustManagerImpl_symantec_distrust.patch -- Gitee From e4b9d135939e2263146905911ad100424101e305 Mon Sep 17 00:00:00 2001 From: laokz Date: Wed, 29 Jun 2022 14:50:14 +0800 Subject: [PATCH 2/2] fix(riscv64): fix arch data for os_linux.cpp Signed-off-by: laokz --- add-riscv-support.patch | 2 +- openjdk-1.8.0.spec | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/add-riscv-support.patch b/add-riscv-support.patch index 24bb927..b857239 100644 --- a/add-riscv-support.patch +++ b/add-riscv-support.patch @@ -96,7 +96,7 @@ index 2d3880b3..6ec35ec1 100644 {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"}, ++ {EM_RISCV, EM_RISCV, ELFCLASS64, ELFDATA2LSB, (char*)"RISCV"}, }; #if (defined IA32) diff --git a/openjdk-1.8.0.spec b/openjdk-1.8.0.spec index 7bfa316..202f144 100644 --- a/openjdk-1.8.0.spec +++ b/openjdk-1.8.0.spec @@ -932,7 +932,7 @@ Provides: java-%{javaver}-%{origin}-accessibility%{?1} = %{epoch}:%{version}-%{r Name: java-%{javaver}-%{origin} Version: %{javaver}.%{updatever}.%{buildver} -Release: 3 +Release: 4 # 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 @@ -2280,6 +2280,9 @@ cjc.mainProgram(arg) %endif %changelog +* Wed Jun 29 2022 laokz - 1:1.8.0.332-b09.4 +- Fix RISC-V patch to os_linux.cpp + * Fri May 06 2022 misaka00251 - 1:1.8.0.332-b09.3 - Fix RISC-V support & merge 22.03-LTS branch -- Gitee