Get the JDK source (per the OpenJDK instructions):
hg clone http://hg.openjdk.java.net/portola/portola
cd portola
bash ./get_source.sh
You need an existing Alpine with an already-built JDK. I have a Docker image of Alpine with glibc-based Zulu JDK:
docker run -ti --volume $PWD:/code delitescere/jdk sh
In the container, we need to grab the Alpine 3.4 package repo also in order to limit to g++ less than version 6:
echo 'http://dl-cdn.alpinelinux.org/alpine/v3.4/main/' >> /etc/apk/repositories
apk update
apk add 'g++<6'
apk add alsa-lib-dev bash cups-dev file freetype-dev grep libelf-dev libx11-dev libxext-dev libxrender-dev libxt-dev libxtst-dev linux-headers make mercurial tar zip
unset JAVA_HOME
cd /code
bash ./configure
The --host=x86_64-unknown-linux-musl --build=x86_64-unknown-linux-musl
arguments are no longer needed.
I've added libelf-dev
so AOT can happen (it's a Linux, after all).
If you are running Alpine version 3.3 or below (or until warnings-are-errors
is disabled in jdk/make/lib/SoundLibraries.gmk
):
ln -snf /usr/include/poll.h /usr/include/sys/poll.h
Make:
make
And have a nice cup of tea while you wait.
Now, back to your host and run the official, vanilla Alpine (no glibc):
docker run -ti --rm --volume $PWD:/code alpine:3.5 /code/build/linux-x86_64-normal-server-release/jdk/bin/java -version
# openjdk version "10-internal"
# OpenJDK Runtime Environment (build 10-internal+0-adhoc..code)
# OpenJDK 64-Bit Server VM (build 10-internal+0-adhoc..code, mixed mode)
Huzzah!
Alas, building with Alpine 3.5 (which defaults to g++ 6.2) yields these C++ compilation issues with the
min
max
macros: