From c7bc562078556c27685a5b8ac5959f194adf5672 Mon Sep 17 00:00:00 2001 From: panxuefeng Date: Wed, 26 Oct 2022 14:23:23 +0800 Subject: [PATCH] Support for Loongson jdk build --- .github/regex_labeler.yml | 3 +++ .github/workflows/build.yml | 4 ++++ README.md | 6 ++--- build-farm/make-adopt-build-farm.sh | 1 + .../platform-specific-configurations/linux.sh | 11 +++++++++ configureBuild.sh | 2 ++ sbin/build.sh | 23 +++++++++++++++++++ sbin/common/common.sh | 2 +- sbin/common/config_init.sh | 2 ++ sbin/common/constants.sh | 3 ++- sbin/prepareWorkspace.sh | 3 ++- .../src/net/adoptium/test/JdkPlatform.java | 5 +++- 12 files changed, 58 insertions(+), 7 deletions(-) diff --git a/.github/regex_labeler.yml b/.github/regex_labeler.yml index 80fb64214f..47249085e8 100644 --- a/.github/regex_labeler.yml +++ b/.github/regex_labeler.yml @@ -92,6 +92,9 @@ labels: - label: "bisheng" matcher: body: "bisheng" + - label: "loongson" + matcher: + body: "loongson" - label: "docker" matcher: body: "docker" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6740bf2152..03d81c56b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/README.md b/README.md index bc04d03b14..4ccfd6e96b 100644 --- a/README.md +++ b/README.md @@ -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 ) +./makejdk-any-platform.sh (-J /usr/lib/jvm/jdk-xx) (--build-variant ) ``` e.g. @@ -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. ---- diff --git a/build-farm/make-adopt-build-farm.sh b/build-farm/make-adopt-build-farm.sh index 7170eab157..8d3da8ffd1 100755 --- a/build-farm/make-adopt-build-farm.sh +++ b/build-farm/make-adopt-build-farm.sh @@ -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 diff --git a/build-farm/platform-specific-configurations/linux.sh b/build-farm/platform-specific-configurations/linux.sh index a3d4080855..4954e4b011 100755 --- a/build-farm/platform-specific-configurations/linux.sh +++ b/build-farm/platform-specific-configurations/linux.sh @@ -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 diff --git a/configureBuild.sh b/configureBuild.sh index 66c9ac03cb..72ceba0f4b 100755 --- a/configureBuild.sh +++ b/configureBuild.sh @@ -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 diff --git a/sbin/build.sh b/sbin/build.sh index 545e9e2d32..86b5904f62 100755 --- a/sbin/build.sh +++ b/sbin/build.sh @@ -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 @@ -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]}\"" @@ -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" diff --git a/sbin/common/common.sh b/sbin/common/common.sh index a531c36496..265c3969e7 100755 --- a/sbin/common/common.sh +++ b/sbin/common/common.sh @@ -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}" ] || diff --git a/sbin/common/config_init.sh b/sbin/common/config_init.sh index 95541858fd..703409695e 100755 --- a/sbin/common/config_init.sh +++ b/sbin/common/config_init.sh @@ -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} diff --git a/sbin/common/constants.sh b/sbin/common/constants.sh index c02cfb4317..8e8b523cce 100755 --- a/sbin/common/constants.sh +++ b/sbin/common/constants.sh @@ -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 diff --git a/sbin/prepareWorkspace.sh b/sbin/prepareWorkspace.sh index a2a65557e2..fb0d0d5266 100644 --- a/sbin/prepareWorkspace.sh +++ b/sbin/prepareWorkspace.sh @@ -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" diff --git a/test/functional/buildAndPackage/src/net/adoptium/test/JdkPlatform.java b/test/functional/buildAndPackage/src/net/adoptium/test/JdkPlatform.java index de6dbcb2bc..12b0fa08c9 100644 --- a/test/functional/buildAndPackage/src/net/adoptium/test/JdkPlatform.java +++ b/test/functional/buildAndPackage/src/net/adoptium/test/JdkPlatform.java @@ -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; } @@ -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 {