Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Loongson jdk build #3134

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/regex_labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ labels:
- label: "bisheng"
matcher:
body: "bisheng"
- label: "loongson"
matcher:
body: "loongson"
- label: "docker"
matcher:
body: "docker"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ jobs:
version: jdk11u
variant: bisheng
image: adoptopenjdk/centos7_build_image
- os: linux
version: jdk8u
variant: loongson
image: adoptopenjdk/centos7_build_image
steps:
- uses: actions/checkout@v3

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ you are building (although one of the same major version will also work).
Note that the build variant defaults to HotSpot if omitted which builds from the same repositories as Temurin.

```bash
./makejdk-any-platform.sh (-J /usr/lib/jvm/jdk-xx) (--build-variant <hotspot|openj9|corretto|SapMachine|dragonwell|bisheng>) <jdk8u|jdk11u|jdk16u|jdk>
./makejdk-any-platform.sh (-J /usr/lib/jvm/jdk-xx) (--build-variant <hotspot|openj9|corretto|SapMachine|dragonwell|bisheng|loongson>) <jdk8u|jdk11u|jdk17u|jdk>
```

e.g.
Expand Down Expand Up @@ -366,9 +366,9 @@ This tag identifies the architecture the JDK has been built on and it intended t
----

- `variant:`
Example values: [`hotspot`, `openj9`, `corretto`, `dragonwell`, `bisheng`]
Example values: [`hotspot`, `openj9`, `corretto`, `dragonwell`, `bisheng`, `loongson`]

This tag identifies the JVM being used by the JDK. "dragonwell" and "bisheng" itself are HotSpot based JVMs but are currently considered their own variants for the purposes of build.
This tag identifies the JVM being used by the JDK. "dragonwell", "bisheng", and "loongson" itself are HotSpot based JVMs but are currently considered their own variants for the purposes of build.
WARN: This will be changed at a later date when we split out JVM from vendor.

----
Expand Down
13 changes: 7 additions & 6 deletions build-farm/make-adopt-build-farm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ PLATFORM_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ -z "$ARCHITECTURE" ]; then
ARCHITECTURE=$(uname -p)
if [ "$OSTYPE" = "cygwin" ] || [ "${ARCHITECTURE}" = "unknown" ]; then ARCHITECTURE=$(uname -m); fi # Windows / Alpine
if [ "$ARCHITECTURE" = "x86_64" ]; then ARCHITECTURE=x64; fi # Linux/x64
if [ "$ARCHITECTURE" = "i386" ]; then ARCHITECTURE=x64; fi # Solaris/x64 and mac/x64
if [ "$ARCHITECTURE" = "sparc" ]; then ARCHITECTURE=sparcv9; fi # Solaris/SPARC
if [ "$ARCHITECTURE" = "powerpc" ]; then ARCHITECTURE=ppc64; fi # AIX
if [ "$ARCHITECTURE" = "arm" ]; then ARCHITECTURE=aarch64; fi # mac/aarch64
if [ "$ARCHITECTURE" = "armv7l" ]; then ARCHITECTURE=arm; fi # Linux/arm32
if [ "$ARCHITECTURE" = "x86_64" ]; then ARCHITECTURE=x64; fi # Linux/x64
if [ "$ARCHITECTURE" = "i386" ]; then ARCHITECTURE=x64; fi # Solaris/x64 and mac/x64
if [ "$ARCHITECTURE" = "sparc" ]; then ARCHITECTURE=sparcv9; fi # Solaris/SPARC
if [ "$ARCHITECTURE" = "powerpc" ]; then ARCHITECTURE=ppc64; fi # AIX
if [ "$ARCHITECTURE" = "arm" ]; then ARCHITECTURE=aarch64; fi # mac/aarch64
if [ "$ARCHITECTURE" = "loongarch64" ]; then ARCHITECTURE=loongarch64; fi # loongarch64
if [ "$ARCHITECTURE" = "armv7l" ]; then ARCHITECTURE=arm; fi # Linux/arm32
echo ARCHITECTURE not defined - assuming $ARCHITECTURE
export ARCHITECTURE
fi
Expand Down
14 changes: 14 additions & 0 deletions build-farm/platform-specific-configurations/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ if [ "${VARIANT}" == "${BUILD_VARIANT_DRAGONWELL}" ] && [ "$JAVA_FEATURE_VERSION
fi
fi

if [ "${VARIANT}" == "${BUILD_VARIANT_LOONGSON}" ]; then
if [ "$JAVA_FEATURE_VERSION" -ne 8 ]; then
echo "Only Java 8 is supported for now"
exit 1
fi
if [ "${ARCHITECTURE}" == "loongarch64" ]; then
export LANG=C
echo Loongson jdk8 requires a Loongson boot JDK - downloading one ...
mkdir -p "$PWD/jdk-8"
curl -L "https://github.com/loongson/build-tools/releases/download/2022.09.06/loongson8.1.11-jdk8u332b09-linux-loongarch64-clfs-6.3-0.tar.gz" | tar xpzf - --strip-components=1 -C "$PWD/jdk-8"
export "${BOOT_JDK_VARIABLE}"="$PWD/jdk-8"
fi
fi

if [ ! -d "$(eval echo "\$$BOOT_JDK_VARIABLE")" ]; then
bootDir="$PWD/jdk-$JDK_BOOT_VERSION"
# Note we export $BOOT_JDK_VARIABLE (i.e. JDKXX_BOOT_DIR) here
Expand Down
2 changes: 2 additions & 0 deletions configureBuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ setRepository() {
suffix="adoptium/jdk11u-fast-startup-incubator"
elif [[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_BISHENG}" ]]; then
suffix="openeuler-mirror/bishengjdk-${BUILD_CONFIG[OPENJDK_CORE_VERSION]:3}"
elif [[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_LOONGSON}" ]]; then
suffix="loongson/jdk8u"
elif [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK8_CORE_VERSION}" ] && [ "${BUILD_CONFIG[OS_ARCHITECTURE]}" == "armv7l" ] && [[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_TEMURIN}" ]]; then
suffix="adoptium/aarch32-jdk8u";
elif [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK8_CORE_VERSION}" ] && [ "${BUILD_CONFIG[OS_ARCHITECTURE]}" == "armv7l" ] && [[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_HOTSPOT}" ]]; then
Expand Down
24 changes: 24 additions & 0 deletions sbin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,21 @@ getOpenJdkVersion() {
version=${BUILD_CONFIG[TAG]:-$(getFirstTagFromOpenJDKGitRepo)}
version=$(echo "$version" | cut -d'-' -f 2 | cut -d'_' -f 1)
fi
elif [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_LOONGSON}" ]; then
local loongsonVerFile="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/scmref.txt"
if [ -r "${loongsonVerFile}" ]; then
if [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK8_CORE_VERSION}" ]; then
local updateNum="$(cat "$loongsonVerFile" | awk -F - '{print $1}' | awk -F u '{print $2}')"
local buildNum="$(cat "$loongsonVerFile" | awk -F - '{print $2}')"
version="jdk8u${updateNum}-${buildNum}"
else
echo "Only Java 8 is supported for now"
exit 1
fi
else
version=${BUILD_CONFIG[TAG]:-$(getFirstTagFromOpenJDKGitRepo)}
version=$(echo "$version" | cut -d'-' -f 2 | cut -d'_' -f 1)
fi
else
version=${BUILD_CONFIG[TAG]:-$(getFirstTagFromOpenJDKGitRepo)}
# TODO remove pending #1016
Expand Down Expand Up @@ -303,6 +318,11 @@ configureVersionStringParameter() {
BUILD_CONFIG[VENDOR_VERSION]="Bisheng"
BUILD_CONFIG[VENDOR_BUG_URL]="https://gitee.com/openeuler/bishengjdk-${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}/issues"
BUILD_CONFIG[VENDOR_VM_BUG_URL]="https://gitee.com/openeuler/bishengjdk-${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}/issues"
elif [[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_LOONGSON}" ]]; then
BUILD_CONFIG[VENDOR]="Loongson"
BUILD_CONFIG[VENDOR_VERSION]="Loongson"
BUILD_CONFIG[VENDOR_BUG_URL]="https://github.com/loongson/jdk8u/issues"
BUILD_CONFIG[VENDOR_VM_BUG_URL]="https://github.com/loongson/jdk8u/issues"
fi
if [ "${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" != 8 ]; then
addConfigureArg "--with-vendor-name=" "\"${BUILD_CONFIG[VENDOR]}\""
Expand Down Expand Up @@ -1379,6 +1399,10 @@ getFirstTagFromOpenJDKGitRepo() {
TAG_SEARCH="aarch64-shenandoah-jdk8u*-b*"
fi

if [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_LOONGSON}" ]; then
TAG_SEARCH="jdk8u*ls-*"
fi

# If openj9 and the closed/openjdk-tag.gmk file exists which specifies what level the openj9 jdk code is based upon,
# read OPENJDK_TAG value from that file.
local openj9_openjdk_tag_file="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}/closed/openjdk-tag.gmk"
Expand Down
2 changes: 1 addition & 1 deletion sbin/common/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function setBootJdk() {
# A function that returns true if the variant is based on HotSpot and should
# be treated as such by the build scripts
# This is possibly only used in configureBuild.sh for arm32
# But should perhaps just be "if not openj9" to include Dragonwell/Bisheng
# But should perhaps just be "if not openj9" to include Dragonwell/Bisheng/Loongson
function isHotSpot() {
[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_HOTSPOT}" ] ||
[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_TEMURIN}" ] ||
Expand Down
2 changes: 2 additions & 0 deletions sbin/common/config_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ function setBranch() {
else
branch="master"
fi
elif [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_LOONGSON}" ]; then
branch="master-ls";
fi

BUILD_CONFIG[BRANCH]=${BUILD_CONFIG[BRANCH]:-$branch}
Expand Down
3 changes: 2 additions & 1 deletion sbin/common/constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ export BUILD_VARIANT_CORRETTO="corretto"
export BUILD_VARIANT_SAP="SapMachine"
export BUILD_VARIANT_DRAGONWELL="dragonwell"
export BUILD_VARIANT_BISHENG="bisheng"
export BUILD_VARIANT_LOONGSON="loongson"
export BUILD_VARIANT_FAST_STARTUP="fast_startup"
export BUILD_VARIANTS="${BUILD_VARIANT_HOTSPOT} ${BUILD_VARIANT_TEMURIN} ${BUILD_VARIANT_OPENJ9} ${BUILD_VARIANT_CORRETTO} ${BUILD_VARIANT_SAP} ${BUILD_VARIANT_DRAGONWELL} ${BUILD_VARIANT_FAST_STARTUP} ${BUILD_VARIANT_BISHENG}"
export BUILD_VARIANTS="${BUILD_VARIANT_HOTSPOT} ${BUILD_VARIANT_TEMURIN} ${BUILD_VARIANT_OPENJ9} ${BUILD_VARIANT_CORRETTO} ${BUILD_VARIANT_SAP} ${BUILD_VARIANT_DRAGONWELL} ${BUILD_VARIANT_FAST_STARTUP} ${BUILD_VARIANT_BISHENG} ${BUILD_VARIANT_LOONGSON}"

# Git Tags to peruse
export GIT_TAGS_TO_SEARCH=100
Expand Down
3 changes: 2 additions & 1 deletion sbin/prepareWorkspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ checkoutAndCloneOpenJDKGitRepo() {
# eg. origin git@github.com:adoptium/openjdk-jdk.git (fetch)
# eg. origin https://github.com/alibaba/dragonwell8.git (fetch)
# eg. origin https://github.com/feilongjiang/bishengjdk-11-mirror.git (fetch)
if [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_DRAGONWELL}" ] || [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_BISHENG}" ]; then
# eg. origin git@github.com/loongson/jdk8u.git (fetch)
if [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_DRAGONWELL}" ] || [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_BISHENG}" ] || [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_LOONGSON}" ]; then
git --git-dir "${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}/.git" remote -v | grep "origin.*fetch" | grep -E "${BUILD_CONFIG[REPOSITORY]}.git|${BUILD_CONFIG[REPOSITORY]}\s"
else
git --git-dir "${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}/.git" remote -v | grep "origin.*fetch" | grep "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" | grep -E "${BUILD_CONFIG[REPOSITORY]}.git|${BUILD_CONFIG[REPOSITORY]}\s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ private static Architecture detectArchitecture() {
if (arch.equals("riscv64")) {
return Architecture.RISCV64;
}
if (arch.equals("loongarch64")) {
return Architecture.LOONGARCH64;
}
if (arch.matches("^(sparc|sparc32)$")) {
return Architecture.SPARC32;
}
Expand Down Expand Up @@ -174,7 +177,7 @@ private static String normalize(final String str) {
}

enum Architecture {
ARM, AARCH64, PPC64, PPC64LE, RISCV, RISCV64, SPARC32, SPARC64, S390X, X64, X86
ARM, AARCH64, PPC64, PPC64LE, RISCV, RISCV64, LOONGARCH64, SPARC32, SPARC64, S390X, X64, X86
}

enum OperatingSystem {
Expand Down