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

1k views Asked by At

The default OpenJ9 build instructions use Docker, but I'd like to compile without Docker; specifically, on RHEL 7.3.

2

There are 2 answers

1
sunnychan77 On BEST ANSWER

The build instructions on RHEL 7 (Or CentOS) should be fairly similar to OpenJDK with HotSpot.

I have a DockerFile that creates an OpenJ9 development environment based on CentOS 7. But if you want to create the environment manually, do this:

  • Grab the build dependency for compiling OpenJDK
    yum builddep java-1.8.0-openjdk

  • Grab the rest of the build dependencies which are not installed in the minimal centos image.

    • java-1.8.0-openjdk-devel for a "Boot" JDK
    • hg, file, which, unzip, make for compiling
    • numactl-devel is needed for J9 numa support
      yum install java-1.8.0-openjdk-devel make file which unzip hg numactl-devel
  • grab a git 2 package from WANDisco:
    rpm -U http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm && yum install -y git

    • Of course you can always modify the build file to make it work with git 1.7, as suggested
  • download freemarker and put the location into ./configure

0
kgibm On

I got this working by looking at the Dockerfile and making a few changes for Fedora-based systems:

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)

Patch for older 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)