Bootstrapping OpenJDK for a new architecture

Bootstrapping using the upstream source

Install build dependencies

First install the basic build dependencies:

# apt -y build-dep openjdk-11
# apt install mercurial

Then install the cross-toolchain as well as the OpenJDK build dependencies for the target:

# apt install gcc-sh4-linux-gnu g++-sh4-linux-gnu
# dpkg --add-architecture sh4
# echo "deb [arch=sh4] unstable main" >> /etc/apt/sources.list
# apt update
# apt install libffi-dev:sh4 libfreetype6-dev:sh4 libx11-dev:sh4 libxext-dev:sh4 libxrender-dev:sh4 libxtst-dev:sh4 libxi-dev:sh4

(If there is no pre-built cross-toolchain package for your arch, use Helmut's rebootstrap script from to create some)

Check out OpenJDK from Mercurial

$ hg clone

Cross-build OpenJDK for a new architecture

It's recommended to start with the Zero JVM which is available on all architectures (it includes Zero assembly code).

$ cd hs
$ CONF=linux-sh-zero-release MAKE_VERBOSE=y QUIETLY= LOG=debug make clean CONF=linux-sh-zero-release ; sh ./configure --build=x86_64-linux-gnu --host=sh4-linux-gnu --target=sh4-linux-gnu --with-jvm-variants=zero --with-boot-jdk=/usr/lib/jvm/java-11-openjdk-amd64/ --disable-precompiled-headers --disable-warnings-as-errors BUILD_CC=sh4-linux-gnu-gcc BUILD_LD=sh4-linux-gnu-ld BUILD_CXX=sh4-linux-gnu-g++ && make JOBS=32 MAKE_VERBOSE=y QUIETLY= LOG=debug CONF=linux-sh-zero-release images

Copy cross-built OpenJDK to target system

$ scp -r build/linux-sh-zero-relase target-host:/path/for/openjdk

Build Debian package on target machine

Download sources for Debian package

$ dget -u
$ cd openjdk-11-11.0.7+10/
$ dpkg-buildpackage -nc -d -B


$ dget -u
$ DEB_BUILD_OPTIONS="nobench nocheck" sbuild --host=sh4 --no-arch-all openjdk-11_11.0.7%2B10-3.dsc