axiangyushanhaijing / powerpoint

https://wiki.openjdk.java.net/display/jdk8u
GNU General Public License v2.0
6 stars 3 forks source link

构建过程 #2

Open axiangyushanhaijing opened 2 years ago

axiangyushanhaijing commented 2 years ago

1、打上patch

diff --git jdk8u/common/autoconf/platform.m4 jdk8u/common/autoconf/platform.m4
index 945579d6..20a48291 100644
--- jdk8u/common/autoconf/platform.m4
+++ jdk8u/common/autoconf/platform.m4
@@ -96,6 +96,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 jdk8u/hotspot/src/os/linux/vm/os_linux.cpp jdk8u/hotspot/src/os/linux/vm/os_linux.cpp
index 2d3880b3..17a5ccfb 100644
--- jdk8u/hotspot/src/os/linux/vm/os_linux.cpp
+++ jdk8u/hotspot/src/os/linux/vm/os_linux.cpp
@@ -1954,6 +1954,10 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen)
   #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"},
     {EM_486,         EM_386,     ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"},
@@ -1976,6 +1980,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)
@@ -2008,9 +2013,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 +2050,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) {

git apply java-1.8.0-riscv-1.patch

2、执行: bash common/autoconf/autogen.sh

3、构建

CC=/opt/riscv64/bin/riscv64-unknown-linux-gnu-gcc \
CXX=/opt/riscv64/bin/riscv64-unknown-linux-gnu-g++ \
bash configure \
--with-sysroot=/opt/riscv64/sysroot \
--openjdk-target=riscv64-unknown-linux-gnu \
--with-boot-jdk=/home/dingli/zulu7.52.0.11-ca-jdk7.0.332-linux_x64 \
--with-jvm-variants=zero \
--with-debug-level=release \
--with-native-debug-symbols=none \
--x-includes=/opt/riscv64/sysroot/usr/include/X11/extension \
--x-libraries=/opt/riscv64/sysroot/usr/lib \
--with-cups=/opt/riscv64/sysroot/usr/include/cups \
--with-freetype-include=/opt/riscv64/sysroot/usr/include/freetype2 \
--with-freetype-lib=/opt/riscv64/sysroot/usr/lib \
--with-extra-cflags="-Wno-error" 
axiangyushanhaijing commented 2 years ago

slowdebug构建

CC=/opt/riscv64/bin/riscv64-unknown-linux-gnu-gcc \
CXX=/opt/riscv64/bin/riscv64-unknown-linux-gnu-g++ \
bash configure \
--with-sysroot=/opt/riscv64/sysroot \
--openjdk-target=riscv64-unknown-linux-gnu \
--with-boot-jdk=/home/zhangxiang/jdk-7/java-se-7u75-ri \
--with-jvm-variants=core \
--with-debug-level=slowdebug \
--with-native-debug-symbols=internal \
--x-includes=/opt/riscv64/sysroot/usr/include/X11/extension \
--x-libraries=/opt/riscv64/sysroot/usr/lib \
--with-cups=/opt/riscv64/sysroot/usr/include/cups \
--with-freetype-include=/opt/riscv64/sysroot/usr/include/freetype2 \
--with-freetype-lib=/opt/riscv64/sysroot/usr/lib \
--with-extra-cflags="-Wno-error" 
axiangyushanhaijing commented 2 years ago

aarch64的编译命令

bash configure \
--with-boot-jdk=/root/jdk8u345-b01 \
--with-jvm-variants=core \
--with-debug-level=slowdebug \
--with-freetype-include=/usr/include/freetype2 \
--with-freetype-lib=/usr/lib/aarch64-linux-gnu \
--with-extra-cflags="-Wno-error"
#make LOG=info > x86_make.log

其中一个报错解决方法 解决方法

axiangyushanhaijing commented 11 months ago

https://github.com/openjdk-riscv/jdk11u/issues/408