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] http://ftp.ports.debian.org/debian-ports/ 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 libjpeg62-dev:sh4 libpng-dev:sh4 libgif-dev:sh4 libasound2-dev:sh4
(If there is no pre-built cross-toolchain package for your arch, use Helmut's rebootstrap script from https://salsa.debian.org/helmutg/rebootstrap to create some)
Check out OpenJDK from Mercurial
$ hg clone http://hg.openjdk.java.net/jdk/jdk
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-20-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++ --with-pcsclite=system --with-libjpeg=system --with-giflib=system --with-libpng=system && make JOBS=80 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 http://snapshot.debian.org/archive/debian/20200416T144937Z/pool/main/o/openjdk-11/openjdk-11_11.0.7%2B10-3.dsc $ cd openjdk-11-11.0.7+10/ $ dpkg-buildpackage -nc -d -B
Cross-building
$ dget -u http://snapshot.debian.org/archive/debian/20200416T144937Z/pool/main/o/openjdk-11/openjdk-11_11.0.7%2B10-3.dsc $ DEB_BUILD_OPTIONS="nobench nocheck" sbuild --host=sh4 --no-arch-all openjdk-11_11.0.7%2B10-3.dsc