Building different VM variants - openeuler-riscv/riscv-port-jdk8u GitHub Wiki
注意需要先按照 Preparation 构建好编译环境
--with-jvm-variants是一个用于配置 Java 虚拟机(JVM)构建的选项,可以指定要编译的 JVM 变体(variants)类型,不同变体针对不同的场景优化,从而满足不同的性能、资源占用或功能需求。
常用于调试的几种JVM:
- zero VM: 无优化、纯解释执行的 JVM,用于调试或跨平台兼容
- core VM: 只包含模板解释器等基础组件,可用于非JIT调试
- client/server VM: 启用C1/C2 JIT 不指定的时候默认使用server VM进行构建。
zero VM构建步骤见 Building JDK‐8 zero VM for RISC‐V platforms ,以下步骤以core VM为例。
$ wget https://mirrors.tuna.tsinghua.edu.cn/Adoptium/8/jdk/x64/linux/OpenJDK8U-jdk_x64_linux_hotspot_8u442b06.tar.gz
$ tar -xzvf OpenJDK8U-jdk_x64_linux_hotspot_8u442b06.tar.gz
$ git clone -b oerv-dev-core-8u352b05-base https://github.com/openeuler-riscv/riscv-port-jdk8u.git
CC=<path-to-toolchain>/riscv64-unknown-linux-gnu-gcc \
CXX=<path-to-toolchain>/riscv64-unknown-linux-gnu-g++ \
bash configure \
--with-sysroot=<path-to-toolchain>/sysroot \
--openjdk-target=riscv64-unknown-linux-gnu \
--with-boot-jdk=<path-to-bootjdk>/jdk8u442-b06 \
--with-jvm-variants=core \
--with-debug-level=release \
--with-native-debug-symbols=none \
--x-includes=<path-to-toolchain>/sysroot/usr/include/X11/extension \
--x-libraries=<path-to-toolchain>/sysroot/usr/lib \
--with-cups=<path-to-toolchain>/sysroot/usr/include/cups \
--with-freetype-include=<path-to-toolchain>/sysroot/usr/include/freetype2 \
--with-freetype-lib=<path-to-toolchain>/sysroot/usr/lib \
--with-extra-cflags="-Wno-error"
将命令中的<path-to-xx>替换成实际路径即可。
$ make JOBS=$(nproc/2) CONF=linux-riscv64-normal-core-release images
生成的镜像位于build/linux-riscv64-normal-core-release/images/j2sdk-image