如何在 Fedora/RHEL/CentOS 上编译 OpenJ9?

How do I compile OpenJ9 on Fedora/RHEL/CentOS?

默认OpenJ9 build instructions使用Docker,但我想编译时不使用Docker;具体来说,在 RHEL 7.3 上。

我通过查看 Dockerfile 并对基于 Fedora 的系统进行一些更改来实现此功能:

sudo yum install autoconf ca-certificates ccache cpio file gcc-c++ gcc git \
                 git-core alsa-lib-devel cups-devel elfutils-devel \
                 freetype-devel numactl-devel libX11-devel libXext-devel \
                 libXrender-devel libXt-devel libXtst-devel make \
                 java-1.8.0-openjdk-devel pkgconfig coreutils \
                 openssh-clients unzip wget zip
# Put java-1.8.0-openjdk-devel at the front of the PATH; for example:
export PATH=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.el7_3.x86_64/bin/:${PATH}
cd ~/
wget https://sourceforge.net/projects/freemarker/files/freemarker/2.3.8/freemarker-2.3.8.tar.gz/download -O freemarker.tgz
tar -xzf freemarker.tgz freemarker-2.3.8/lib/freemarker.jar --strip=2
rm -f freemarker.tgz
git clone https://github.com/ibmruntimes/openj9-openjdk-jdk9
cd openj9-openjdk-jdk9
bash ./get_source.sh
# I'm on RHEL 7.3 with git 1.8 which doesn't support -C ${DIR}, so that
# needs to change to --work-tree=${DIR} --git-dir=${DIR}/.git
# Apply the patch at the bottom of this answer now before continuing.
bash ./configure --with-freemarker-jar=~/freemarker.jar
make all

[...]
Finished building target 'all' in configuration 'linux-x86_64-normal-server-release'

build/linux-x86_64-normal-server-release/images/jre/bin/java -version

openjdk version "9-internal"
OpenJDK Runtime Environment (build 9-internal+0-adhoc.kevin.openj9-openjdk-jdk9)
Eclipse OpenJ9 VM (build 2.9, JRE 9 Linux amd64-64 Compressed References 20170915_000000 (JIT enabled, AOT enabled)
J9VM - ead54ef
JIT - ead54ef
OMR - 617de12
OpenJDK - f38f4d6 based on jdk-9+181)

旧 Git 1.8 的补丁:

diff --git a/closed/OpenJ9.gmk b/closed/OpenJ9.gmk
index 977fb40..2d19477 100755
--- a/closed/OpenJ9.gmk
+++ b/closed/OpenJ9.gmk
@@ -27,8 +27,8 @@ ifeq (,$(BUILD_ID))
  BUILD_ID := 000000
endif

-OPENJ9_SHA    := $(shell git -C $(OPENJ9_TOPDIR)    rev-parse --short HEAD)
-OPENJ9OMR_SHA := $(shell git -C $(OPENJ9OMR_TOPDIR) rev-parse --short HEAD)
+OPENJ9_SHA    := $(shell git --work-tree=$(OPENJ9_TOPDIR) --git-dir=$(OPENJ9_TOPDIR)/.git    rev-parse --short HEAD)
+OPENJ9OMR_SHA := $(shell git --work-tree=$(OPENJ9OMR_TOPDIR) --git-dir=$(OPENJ9OMR_TOPDIR)/.git rev-parse --short HEAD)
ifeq (,$(OPENJ9_SHA))
  $(error Could not determine OpenJ9 SHA)
endif
diff --git a/closed/autoconf/custom-hook.m4 b/closed/autoconf/custom-hook.m4
index 30d8a98..ed8e6af 100644
--- a/closed/autoconf/custom-hook.m4
+++ b/closed/autoconf/custom-hook.m4
@@ -127,8 +127,8 @@ AC_DEFUN_ONCE([OPENJ9_PLATFORM_SETUP],

AC_DEFUN_ONCE([OPENJDK_VERSION_DETAILS],
[
-  OPENJDK_SHA=`git -C $SRC_ROOT rev-parse --short HEAD`
-  OPENJDK_TAG=`git -C $SRC_ROOT describe --abbrev=0 --tags`
+  OPENJDK_SHA=`git --work-tree=$SRC_ROOT --git-dir=$SRC_ROOT/.git rev-parse --short HEAD`
+  OPENJDK_TAG=`git --work-tree=$SRC_ROOT --git-dir=$SRC_ROOT/.git describe --abbrev=0 --tags`
  AC_SUBST(OPENJDK_SHA)
  AC_SUBST(OPENJDK_TAG)
])
diff --git a/closed/make/ReleaseFile.gmk b/closed/make/ReleaseFile.gmk
index d6be94c..2feca5b 100644
--- a/closed/make/ReleaseFile.gmk
+++ b/closed/make/ReleaseFile.gmk
@@ -16,8 +16,8 @@
# 2 along with this work; if not, see <http://www.gnu.org/licenses/>.
# 
# ===========================================================================
-
-COMPANY_NAME := Eclipse OpenJ9
-OPENJ9OMR_SHA := $(shell git -C $(OPENJ9OMR_TOPDIR) rev-parse --short HEAD)
-OPENJ9_SHA  := $(shell git -C $(OPENJ9_TOPDIR)  rev-parse --short HEAD)
-SOURCE_REVISION = OpenJDK:$(OPENJDK_SHA) OpenJ9:$(OPENJ9_SHA) OMR:$(OPENJ9OMR_SHA)
+
+COMPANY_NAME := Eclipse OpenJ9
+OPENJ9OMR_SHA := $(shell git --work-tree=$(OPENJ9OMR_TOPDIR) --git-dir=$(OPENJ9OMR_TOPDIR)/.git rev-parse --short HEAD)
+OPENJ9_SHA  := $(shell git --work-tree=$(OPENJ9_TOPDIR) --git-dir=$(OPENJ9_TOPDIR)/.git  rev-parse --short HEAD)
+SOURCE_REVISION = OpenJDK:$(OPENJDK_SHA) OpenJ9:$(OPENJ9_SHA) OMR:$(OPENJ9OMR_SHA)

RHEL 7(或 CentOS)上的构建说明应该与 OpenJDK with HotSpot 非常相似。

我有一个 DockerFile 可以创建一个基于 CentOS 7 的 OpenJ9 开发环境。但是如果您想手动创建环境,请执行以下操作:

  • 获取编译Open的构建依赖JDK
    yum builddep java-1.8.0-openjdk

  • 获取最小 centos 映像中未安装的其余构建依赖项。

    • java-1.8.0-openjdk-devel 对于 "Boot" JDK
    • hg, file, which, unzip, make 编译
    • J9 numa 支持需要 numactl-devel
      yum install java-1.8.0-openjdk-devel make file which unzip hg numactl-devel
  • 从 WANDisco 获取一个 git 2 软件包:
    rpm -U <a href="http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm" rel="nofollow noreferrer">http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm</a> && yum install -y git

    • 当然,您可以随时修改构建文件,使其与 git 1.7 一起使用,如建议的那样
  • 下载freemarker并将位置放入./configure