Last active
October 19, 2020 14:30
-
-
Save etki/1b69a0c87d359d9047588da7a5612359 to your computer and use it in GitHub Desktop.
Building hsdis for multiple java versions and architectures on linux using docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -eu | |
source "$HOME/.jabba/jabba.sh" | |
OPTIONS="-XX:+UnlockDiagnosticVMOptions" | |
OPTIONS="$OPTIONS -XX:CompileCommand=print,Main.main" | |
for VERSION in 9.0 10.0 11.0 12.0 13.0 14.0-27; do | |
MAJOR="$(echo $VERSION | cut -d . -f 1)" | |
echo "JDK $MAJOR: Installing JDK" | |
jabba install "openjdk@1.$VERSION" | |
jabba use "openjdk@1.$VERSION" | |
echo "JDK $MAJOR: Installing hsdis" | |
cp -f "/tmp/workspace/hsdis/$MAJOR/hsdis-amd64.so" \ | |
"$HOME/.jabba/jdk/openjdk@1.$VERSION/lib/hsdis-amd64.so" | |
echo "JDK $MAJOR: Compiling" | |
javac /tmp/workspace/Main.java | |
echo "JDK $MAJOR: Launching test" | |
set +e | |
OUTPUT="$(java $OPTIONS -cp /tmp/workspace Main 2>&1)" | |
set -e | |
if [ $? -ne 0 ]; then | |
echo "JDK $MAJOR: Failed running test. Output:" | |
echo "$OUTPUT" | |
continue | |
fi | |
if [ -z "$(echo $OUTPUT | grep -i java/lang)" ]; then | |
echo "JDK $MAJOR: hsdis check failed. Output:" | |
echo "$OUTPUT" | |
continue | |
fi | |
echo "JDK $MAJOR: Success!" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
BINUTILS_2_28_LOCATION="${BINUTILS_2_28_LOCATION:-/tmp/workspace/binutils-2.28}" | |
BINUTILS_2_32_LOCATION="${BINUTILS_2_32_LOCATION:-/tmp/workspace/binutils-2.32}" | |
JDK_SOURCES_LOCATION="${JDK_SOURCES_LOCATION:-/tmp/workspace/jdk}" | |
HSDIS_OUTPUT_LOCATION="${HSDIS_OUTPUT_LOCATION:-/tmp/workspace/hsdis}" | |
BINUTILS_2_28_TARGETS="${BINUTILS_2_28_TARGETS:-jdk7-b147 jdk8-b120 jdk-9+181 jdk-10+46 jdk-11+28}" | |
BINUTILS_2_32_TARGETS="${BINUTILS_2_32_TARGETS:-jdk-12+33 jdk-13+33 jdk-14+24}" | |
set -euo pipefail | |
apt-get update -yq | |
apt-get install build-essential git file -yq | |
build_hsdis() { | |
for OPENJDK_TAG in $2; do | |
OPENJDK_VERSION="$(echo $OPENJDK_TAG | sed 's/jdk\-\?//g' | awk -F'[\-+]' '{print $1}')" | |
OUTPUT_LOCATION="$HSDIS_OUTPUT_LOCATION/$OPENJDK_VERSION" | |
echo "Building hsdis using OpenJDK version $OPENJDK_VERSION ($OPENJDK_TAG)..." | |
mkdir -p "$OUTPUT_LOCATION" | |
cd "$JDK_SOURCES_LOCATION" | |
git checkout -f "$OPENJDK_TAG" | |
git clean -fd | |
cd "$(find . -name hsdis | head -n 1)" | |
echo "Running make..." | |
make BINUTILS="$1" ARCH="$ARCHITECTURE" > "$OUTPUT_LOCATION/make-$ARCHITECTURE.log" 2>&1 | |
cp "$(find build -name hsdis-*.so)" "$OUTPUT_LOCATION/hsdis-$ARCHITECTURE.so" | |
echo "Done!" | |
done | |
} | |
build_hsdis "$BINUTILS_2_28_LOCATION" "$BINUTILS_2_28_TARGETS" | |
build_hsdis "$BINUTILS_2_32_LOCATION" "$BINUTILS_2_32_TARGETS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -eu | |
for ARCHITECTURE in i386 amd64; do | |
docker run --rm \ | |
-e "ARCHITECTURE=$ARCHITECTURE" \ | |
-e "BINUTILS_2_28_LOCATION=/tmp/workspace/binutils-2.28" \ | |
-e "BINUTILS_2_32_LOCATION=/tmp/workspace/binutils-2.32" \ | |
-e "JDK_SOURCES_LOCATION=/tmp/workspace/jdk" \ | |
-e "BINUTILS_2_28_TARGETS=jdk7-b147 jdk8-b120 jdk-9+181 jdk-10+46 jdk-11+28" \ | |
-e "BINUTILS_2_32_TARGETS=jdk-12+33 jdk-13+33 jdk-14+24" \ | |
-e "HSDIS_OUTPUT_LOCATION=/tmp/workspace/hsdis" \ | |
-v /tmp/workspace:/tmp/workspace \ | |
"$ARCHITECTURE/ubuntu:18.04" bash /tmp/workspace/entrypoint.sh | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Main { | |
public static void main(String[] args) { | |
long completion = System.currentTimeMillis() + 1_000; | |
int accumulator = 1; | |
while (System.currentTimeMillis() < completion) { | |
accumulator = permutate(accumulator); | |
} | |
System.exit(accumulator - accumulator); | |
} | |
private static int permutate(int state) { | |
return state * 31; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment