Skip to content

Commit

Permalink
Support for Loongson jdk build
Browse files Browse the repository at this point in the history
  • Loading branch information
Panxuefeng-loongson committed Oct 27, 2022
1 parent ce8eca7 commit c7bc562
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 7 deletions.
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@v2

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|jdk16u|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
1 change: 1 addition & 0 deletions build-farm/make-adopt-build-farm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if [ -z "$ARCHITECTURE" ]; then
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
Expand Down
11 changes: 11 additions & 0 deletions build-farm/platform-specific-configurations/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ if [ "${VARIANT}" == "${BUILD_VARIANT_DRAGONWELL}" ] && [ "$JAVA_FEATURE_VERSION
fi
export "${BOOT_JDK_VARIABLE}"="$PWD/jdk-8"
fi
elif [ "${VARIANT}" == "${BUILD_VARIANT_LOONGSON}" ]; then
if [ "$(uname -m)" = "loongarch64" ]; then
if [ -d /opt/j2sdk-images ]; then
export "${BOOT_JDK_VARIABLE}"=/opt/j2sdk-images
else
echo Loongson jdk8 requires a Loongson boot JDK - downloading one ...
mkdir -p "$PWD/jdk-8"
curl -L "http://ftp.loongnix.cn/Java/openjdk8/loongson8.1.11-jdk8u332b09-linux-loongarch64.tar.gz" | tar xpzf - --strip-components=1 -C "$PWD/jdk-8"
export "${BOOT_JDK_VARIABLE}"="$PWD/jdk-8"
fi
fi
fi

if [ ! -d "$(eval echo "\$$BOOT_JDK_VARIABLE")" ]; then
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
23 changes: 23 additions & 0 deletions sbin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,20 @@ 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[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}/version.txt
if [ -r "${loongsonVerFile}" ]; then
if [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK8_CORE_VERSION}" ]; then
local updateNum="$(cut -d'.' -f 2 <"${loongsonVerFile}")"
local buildNum="$(cut -d'.' -f 5 <"${loongsonVerFile}")"
version="jdk8u${updateNum}-b${buildNum}"
else
echo "not support jdk version!"
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 +317,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]=""
BUILD_CONFIG[VENDOR_VM_BUG_URL]=""
fi
if [ "${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" != 8 ]; then
addConfigureArg "--with-vendor-name=" "\"${BUILD_CONFIG[VENDOR]}\""
Expand Down Expand Up @@ -1379,6 +1398,10 @@ getFirstTagFromOpenJDKGitRepo() {
TAG_SEARCH="aarch64-shenandoah-jdk8u*-b*"
fi

if [ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_LOONGSON}" ]; then
TAG_SEARCH="ls-loongson-jdk8u-init"
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

0 comments on commit c7bc562

Please sign in to comment.