diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..f483e0b0 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,205 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +pipeline { + agent { label 'worker' } + + options { + buildDiscarder(logRotator(numToKeepStr: '30')) + } + + triggers { + cron('H * * * *') + } + + stages { + stage('Validate Parameters') { + steps { + script { + if (!params.SKARA_REPO?.trim()) { + error('SKARA_REPO parameter is required.') + } + if (!(params.SKARA_REPO ==~ /[A-Za-z0-9._-]+/)) { + error('SKARA_REPO must be a valid GitHub repository name.') + } + } + } + } + + stage('Determine Branches') { + steps { + script { + def upstreamRepo = params.SKARA_REPO == 'alpine-jdk8u' ? 'jdk8u' : params.SKARA_REPO + def skaraRepo = "https://github.com/openjdk/${upstreamRepo}" + echo "Upstream SKARA_REPO: ${skaraRepo}" + + // Determine default branch via git ls-remote --symref (no API token needed) + def symrefOutput = sh( + script: "git ls-remote --symref '${skaraRepo}' HEAD", + returnStdout: true + ).trim() + def defaultBranchMatch = symrefOutput =~ /ref: refs\/heads\/(\S+)\s+HEAD/ + if (!defaultBranchMatch) { + error("Could not determine default branch for ${skaraRepo} - git ls-remote --symref output was unexpected:\n${symrefOutput}") + } + def defaultBranch = defaultBranchMatch[0][1] + echo "Default branch: ${defaultBranch}" + + // Do a temporary bare clone with --filter=blob:none to get branch refs and + // commit dates without downloading any file content. + def tmpBareClone = "${env.WORKSPACE}/tmp-bare-${params.SKARA_REPO}" + sh "rm -rf '${tmpBareClone}'" + sh "git clone --bare --filter=blob:none '${skaraRepo}' '${tmpBareClone}'" + + try { + // Staleness threshold: 90 days ago as unix epoch + def threeMonthsAgoStr = sh( + script: "date -d '90 days ago' +%s", + returnStdout: true + ).trim() + if (!threeMonthsAgoStr.isLong()) { + error("Failed to compute staleness threshold: unexpected output: '${threeMonthsAgoStr}'") + } + def threeMonthsAgoEpoch = threeMonthsAgoStr as long + + // List all remote branches from the bare clone + def allBranchesRaw = sh( + script: "git -C '${tmpBareClone}' for-each-ref --format='%(refname:short)' refs/heads/", + returnStdout: true + ).trim() + if (!allBranchesRaw) { + error("No branches found in ${skaraRepo}") + } + + // Filter to active branches by checking last commit date + def branches = [] as Set + for (branch in allBranchesRaw.split('\n')) { + branch = branch.trim() + if (!branch) continue + // Skip upstream PR branches — there can be hundreds and they are not mirrored + if (branch.startsWith('pr/')) continue + def commitEpochStr = withEnv(["BRANCH_TO_CHECK=${branch}"]) { + sh( + script: "git -C '${tmpBareClone}' log -1 --format='%ct' -- \"\$BRANCH_TO_CHECK\"", + returnStdout: true + ).trim() + } + if (!commitEpochStr.isLong()) { + error("Could not determine commit date for branch '${branch}': unexpected output: '${commitEpochStr}'") + } + def commitEpoch = commitEpochStr as long + if (commitEpoch >= threeMonthsAgoEpoch) { + echo "Active branch: ${branch} (epoch: ${commitEpoch})" + branches.add(branch) + } else { + echo "Stale branch (skipping): ${branch} (epoch: ${commitEpoch})" + } + } + + // Ensure the default branch is always included + branches.add(defaultBranch) + + echo "Active branches to mirror: ${branches.join(', ')}" + env.BRANCHES_TO_MIRROR = branches.join(' ') + env.DEFAULT_BRANCH = defaultBranch + } finally { + // Always clean up the temporary bare clone + sh "rm -rf '${tmpBareClone}'" + } + } + } + } + + stage('Clean Mirror Workspace') { + when { + expression { return params.CLEAN_MIRROR_WORKSPACE == true } + } + steps { + script { + def workspaceDir = "${env.WORKSPACE}/workspace/${params.SKARA_REPO}" + echo "Cleaning mirror workspace: ${workspaceDir}" + sh "rm -rf '${workspaceDir}'" + } + } + } + + stage('Mirror Branches') { + steps { + script { + def mirrorRepoArg = params.ADOPTIUM_MIRROR_REPO?.trim() ?: '' + def branchList = env.BRANCHES_TO_MIRROR.tokenize(' ') + + for (branch in branchList) { + echo "--- Mirroring branch: ${branch} ---" + withEnv([ + "BRANCH=${branch}", + "SKARA_REPO_ARG=${params.SKARA_REPO}", + "MIRROR_REPO_ARG=${mirrorRepoArg}" + ]) { + sh ''' + git --version + bash ./skaraMirror.sh "$SKARA_REPO_ARG" "$MIRROR_REPO_ARG" + ''' + } + } + } + } + } + } + + post { + always { + echo 'Mirror job finished.' + } + success { + echo 'All branches mirrored successfully.' + } + unstable { + echo 'Mirror job completed with an unstable result.' + } + failure { + echo 'Mirror job failed.' + script { + // Only notify Slack during 09:00–11:59 UTC to avoid hourly spam. + def utcHour = sh(script: "date -u +%H", returnStdout: true).trim().toInteger() + if (utcHour >= 9 && utcHour < 12) { + slackSend( + channel: '#build', + color: 'danger', + message: "Skara mirror job *FAILED* for `${params.SKARA_REPO ?: 'unknown'}`" + + (params.ADOPTIUM_MIRROR_REPO?.trim() ? " → `${params.ADOPTIUM_MIRROR_REPO}`" : '') + + " (<${env.BUILD_URL}console|Console>)" + ) + } else { + echo "Outside Slack notification window (UTC hour: ${utcHour}) — skipping Slack alert." + } + } + } + aborted { + echo 'Mirror job was aborted.' + } + changed { + echo 'Mirror job result has changed since the last run.' + } + fixed { + echo 'Mirror job is back to success after a previous failure.' + } + regression { + echo 'Mirror job was previously successful but is now failing.' + } + cleanup { + echo 'Mirror job post-processing complete.' + } + } +} diff --git a/patches/aarch32-port-jdk8u/0001-Set-vendor-information.patch b/patches/aarch32-port-jdk8u/0001-Set-vendor-information.patch new file mode 100644 index 00000000..0d2f8eb8 --- /dev/null +++ b/patches/aarch32-port-jdk8u/0001-Set-vendor-information.patch @@ -0,0 +1,32 @@ +From a170d74d4b72563fc70f227a6c7d3e64c4146631 Mon Sep 17 00:00:00 2001 +From: John Oliver +Date: Tue, 6 Nov 2018 10:47:15 +0000 +Subject: [PATCH] Set vendor information + +--- + jdk/src/share/native/java/lang/System.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/jdk/src/share/native/java/lang/System.c b/jdk/src/share/native/java/lang/System.c +index 04ef657465..b06a38f87e 100644 +--- a/jdk/src/share/native/java/lang/System.c ++++ b/jdk/src/share/native/java/lang/System.c +@@ -110,13 +110,13 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x) + + /* Third party may overwrite these values. */ + #ifndef VENDOR +-#define VENDOR "Oracle Corporation" ++#define VENDOR "Eclipse Foundation" + #endif + #ifndef VENDOR_URL +-#define VENDOR_URL "http://java.oracle.com/" ++#define VENDOR_URL "https://adoptium.net/" + #endif + #ifndef VENDOR_URL_BUG +-#define VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/" ++#define VENDOR_URL_BUG "https://github.com/adoptium/adoptium-support/issues" + #endif + + #define JAVA_MAX_SUPPORTED_VERSION 52 +-- +2.7.4 diff --git a/patches/aarch32-port-jdk8u/actions-ignore-branches.patch b/patches/aarch32-port-jdk8u/actions-ignore-branches.patch new file mode 100644 index 00000000..d1107174 --- /dev/null +++ b/patches/aarch32-port-jdk8u/actions-ignore-branches.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Adoptium +Date: Mon, 17 Sep 2001 00:00:00 +0000 +Subject: [PATCH] skip github actions builds to save executors + +--- + .github/workflows/submit.yml | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/.github/workflows/submit.yml b/.github/workflows/submit.yml +index 72e619aa83..887a20c844 100644 +--- a/.github/workflows/submit.yml ++++ b/.github/workflows/submit.yml +@@ -4,6 +4,8 @@ on: + push: + branches-ignore: + - master ++ - dev* ++ - release* + - pr/* + workflow_dispatch: + inputs: +-- +2.39.0 diff --git a/patches/aarch32-port-jdk8u/company_name.patch b/patches/aarch32-port-jdk8u/company_name.patch new file mode 100644 index 00000000..2095e5df --- /dev/null +++ b/patches/aarch32-port-jdk8u/company_name.patch @@ -0,0 +1,91 @@ +From fe098d6310075681475ffece69faf1e8e715b5e9 Mon Sep 17 00:00:00 2001 +From: John Oliver +Date: Thu, 30 Aug 2018 14:22:52 +0100 +Subject: [PATCH] Allow setting company name + +--- + common/autoconf/jdk-options.m4 | 11 +++++++++++ + jdk/make/gensrc/GensrcMisc.gmk | 6 ++++++ + jdk/src/share/classes/sun/misc/Version.java.template | 7 +++++-- + 3 files changed, 22 insertions(+), 2 deletions(-) + +diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 +index 18ba585209..ae9d5308f4 100644 +--- a/common/autoconf/jdk-options.m4 ++++ b/common/autoconf/jdk-options.m4 +@@ -539,6 +539,17 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_VERSION_NUMBERS], + AC_SUBST(MACOSX_BUNDLE_NAME_BASE) + AC_SUBST(MACOSX_BUNDLE_ID_BASE) + ++ # The company name, if any ++ AC_ARG_WITH(company-name, [AS_HELP_STRING([--with-company-name], ++ [Set company name.])]) ++ if test "x$with_company_name" = xyes; then ++ AC_MSG_ERROR([--with-company-name must have a value]) ++ elif [ ! [[ $with_company_name =~ ^[[:print:]]*$ ]] ]; then ++ AC_MSG_ERROR([--with-company-name contains non-printing characters: $with_company_name]) ++ elif test "x$with_company_name" != x; then ++ COMPANY_NAME="$with_company_name" ++ fi ++ + # The vendor name, if any + AC_ARG_WITH(vendor-name, [AS_HELP_STRING([--with-vendor-name], + [Set vendor name. Among others, used to set the 'java.vendor' +diff --git a/jdk/make/gensrc/GensrcMisc.gmk b/jdk/make/gensrc/GensrcMisc.gmk +index 0e3dee5ca3..c137f371c7 100644 +--- a/jdk/make/gensrc/GensrcMisc.gmk ++++ b/jdk/make/gensrc/GensrcMisc.gmk +@@ -30,6 +30,11 @@ include ProfileNames.gmk + # string and the runtime name into the Version.java file. + # To be printed by java -version + ++company_name = ++ifneq ($(COMPANY_NAME),N/A) ++ company_name=($(COMPANY_NAME)) ++endif ++ + $(JDK_OUTPUTDIR)/gensrc/sun/misc/Version.java \ + $(PROFILE_VERSION_JAVA_TARGETS): \ + $(JDK_TOPDIR)/src/share/classes/sun/misc/Version.java.template +@@ -40,6 +45,7 @@ $(PROFILE_VERSION_JAVA_TARGETS): \ + -e 's/@@java_version@@/$(RELEASE)/g' \ + -e 's/@@java_runtime_version@@/$(FULL_VERSION)/g' \ + -e 's/@@java_runtime_name@@/$(RUNTIME_NAME)/g' \ ++ -e 's/@@company_name@@/$(company_name)/g' \ + -e 's/@@java_profile_name@@/$(call profile_version_name, $@)/g' \ + $< > $@.tmp + $(MV) $@.tmp $@ +diff --git a/jdk/src/share/classes/sun/misc/Version.java.template b/jdk/src/share/classes/sun/misc/Version.java.template +index 32e2586e79..b1642d3f0a 100644 +--- a/jdk/src/share/classes/sun/misc/Version.java.template ++++ b/jdk/src/share/classes/sun/misc/Version.java.template +@@ -44,6 +44,9 @@ public class Version { + private static final String java_runtime_version = + "@@java_runtime_version@@"; + ++ private static final String company_name = ++ "@@company_name@@"; ++ + static { + init(); + } +@@ -103,7 +106,7 @@ public class Version { + + /* Second line: runtime version (ie, libraries). */ + +- ps.print(java_runtime_name + " (build " + java_runtime_version); ++ ps.print(java_runtime_name + " " + company_name + "(build " + java_runtime_version); + + if (java_profile_name.length() > 0) { + // profile name +@@ -120,7 +123,7 @@ public class Version { + String java_vm_name = System.getProperty("java.vm.name"); + String java_vm_version = System.getProperty("java.vm.version"); + String java_vm_info = System.getProperty("java.vm.info"); +- ps.println(java_vm_name + " (build " + java_vm_version + ", " + ++ ps.println(java_vm_name + " " + company_name + "(build " + java_vm_version + ", " + + java_vm_info + ")"); + } + +-- +2.7.4 diff --git a/patches/alpine-jdk8u/0002-apply-PATCH-Allow-setting-company-name.patch b/patches/alpine-jdk8u/0002-apply-PATCH-Allow-setting-company-name.patch new file mode 100644 index 00000000..279192e9 --- /dev/null +++ b/patches/alpine-jdk8u/0002-apply-PATCH-Allow-setting-company-name.patch @@ -0,0 +1,92 @@ +From 64e700caf63749a574abf84511420cc22c74217f Mon Sep 17 00:00:00 2001 +From: George Adams +Date: Mon, 6 Dec 2021 11:26:48 +0000 +Subject: [PATCH] apply [PATCH] Allow setting company name + +--- + common/autoconf/jdk-options.m4 | 12 ++++++++++ + jdk/make/gensrc/GensrcMisc.gmk | 6 +++++ + .../classes/sun/misc/Version.java.template | 7 ++++-- + 3 files changed, 23 insertions(+), 2 deletions(-) + +diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 +index 18ba585209..42aeb7bd61 100644 +--- a/common/autoconf/jdk-options.m4 ++++ b/common/autoconf/jdk-options.m4 +@@ -539,6 +539,18 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_VERSION_NUMBERS], + AC_SUBST(MACOSX_BUNDLE_NAME_BASE) + AC_SUBST(MACOSX_BUNDLE_ID_BASE) + ++ # The company name, if any ++ AC_ARG_WITH(company-name, [AS_HELP_STRING([--with-company-name], ++ [Set company name.])]) ++ if test "x$with_company_name" = xyes; then ++ AC_MSG_ERROR([--with-company-name must have a value]) ++ elif [ ! [[ $with_company_name =~ ^[[:print:]]*$ ]] ]; then ++ AC_MSG_ERROR([--with-company-name contains non-printing characters: $with_company_name]) ++ elif test "x$with_company_name" != x; then ++ COMPANY_NAME="$with_company_name" ++ fi ++ AC_SUBST(COMPANY_NAME) ++ + # The vendor name, if any + AC_ARG_WITH(vendor-name, [AS_HELP_STRING([--with-vendor-name], + [Set vendor name. Among others, used to set the 'java.vendor' +diff --git a/jdk/make/gensrc/GensrcMisc.gmk b/jdk/make/gensrc/GensrcMisc.gmk +index 0e3dee5ca3..fc19b082cc 100644 +--- a/jdk/make/gensrc/GensrcMisc.gmk ++++ b/jdk/make/gensrc/GensrcMisc.gmk +@@ -30,6 +30,11 @@ include ProfileNames.gmk + # string and the runtime name into the Version.java file. + # To be printed by java -version + ++company_name = ++ifneq ($(COMPANY_NAME),N/A) ++ company_name=($(COMPANY_NAME)) ++endif ++ + $(JDK_OUTPUTDIR)/gensrc/sun/misc/Version.java \ + $(PROFILE_VERSION_JAVA_TARGETS): \ + $(JDK_TOPDIR)/src/share/classes/sun/misc/Version.java.template +@@ -41,6 +46,7 @@ $(PROFILE_VERSION_JAVA_TARGETS): \ + -e 's/@@java_runtime_version@@/$(FULL_VERSION)/g' \ + -e 's/@@java_runtime_name@@/$(RUNTIME_NAME)/g' \ + -e 's/@@java_profile_name@@/$(call profile_version_name, $@)/g' \ ++ -e 's/@@company_name@@/$(company_name)/g' \ + $< > $@.tmp + $(MV) $@.tmp $@ + +diff --git a/jdk/src/share/classes/sun/misc/Version.java.template b/jdk/src/share/classes/sun/misc/Version.java.template +index 32e2586e79..b1642d3f0a 100644 +--- a/jdk/src/share/classes/sun/misc/Version.java.template ++++ b/jdk/src/share/classes/sun/misc/Version.java.template +@@ -44,6 +44,9 @@ public class Version { + private static final String java_runtime_version = + "@@java_runtime_version@@"; + ++ private static final String company_name = ++ "@@company_name@@"; ++ + static { + init(); + } +@@ -103,7 +106,7 @@ public class Version { + + /* Second line: runtime version (ie, libraries). */ + +- ps.print(java_runtime_name + " (build " + java_runtime_version); ++ ps.print(java_runtime_name + " " + company_name + "(build " + java_runtime_version); + + if (java_profile_name.length() > 0) { + // profile name +@@ -120,7 +123,7 @@ public class Version { + String java_vm_name = System.getProperty("java.vm.name"); + String java_vm_version = System.getProperty("java.vm.version"); + String java_vm_info = System.getProperty("java.vm.info"); +- ps.println(java_vm_name + " (build " + java_vm_version + ", " + ++ ps.println(java_vm_name + " " + company_name + "(build " + java_vm_version + ", " + + java_vm_info + ")"); + } + +-- +2.52.0 diff --git a/patches/alpine-jdk8u/0003-apply-0001-Set-vendor-information.patch.patch b/patches/alpine-jdk8u/0003-apply-0001-Set-vendor-information.patch.patch new file mode 100644 index 00000000..c07a4058 --- /dev/null +++ b/patches/alpine-jdk8u/0003-apply-0001-Set-vendor-information.patch.patch @@ -0,0 +1,33 @@ +From d3b53e6f024d33acce72076d3e2475bf498304b2 Mon Sep 17 00:00:00 2001 +From: George Adams +Date: Mon, 6 Dec 2021 11:08:49 +0000 +Subject: [PATCH] apply 0001-Set-vendor-information.patch + +--- + jdk/src/share/native/java/lang/System.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/jdk/src/share/native/java/lang/System.c b/jdk/src/share/native/java/lang/System.c +index 85dbe575cb..4091b71b82 100644 +--- a/jdk/src/share/native/java/lang/System.c ++++ b/jdk/src/share/native/java/lang/System.c +@@ -110,13 +110,13 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x) + + /* Third party may overwrite these values. */ + #ifndef VENDOR +-#define VENDOR "Oracle Corporation" ++#define VENDOR "Eclipse Foundation" + #endif + #ifndef VENDOR_URL +-#define VENDOR_URL "http://java.oracle.com/" ++#define VENDOR_URL "https://adoptium.net/" + #endif + #ifndef VENDOR_URL_BUG +-#define VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/" ++#define VENDOR_URL_BUG "https://github.com/adoptium/adoptium-support/issues" + #endif + + #define JAVA_MAX_SUPPORTED_VERSION 52 +-- +2.52.0 + diff --git a/patches/alpine-jdk8u/0005-alpine-musl-libc-support.patch b/patches/alpine-jdk8u/0005-alpine-musl-libc-support.patch new file mode 100644 index 00000000..ebe3ea6a --- /dev/null +++ b/patches/alpine-jdk8u/0005-alpine-musl-libc-support.patch @@ -0,0 +1,1379 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Adoptium +Date: Mon, 17 Sep 2001 00:00:00 +0000 +Subject: [PATCH] Add Alpine/musl libc support + +Squashed patch of all Alpine musl libc support changes. +--- +diff --git a/common/autoconf/build-aux/config.guess b/common/autoconf/build-aux/config.guess +index b32ca48dd5..5203fcdb29 100644 +--- a/common/autoconf/build-aux/config.guess ++++ b/common/autoconf/build-aux/config.guess +@@ -30,6 +30,17 @@ + DIR=`dirname $0` + OUT=`. $DIR/autoconf-config.guess` + ++# Detect C library. ++# Use '-gnu' suffix on systems that use glibc. ++# Use '-musl' suffix on systems that use the musl libc. ++echo $OUT | grep -- -linux- > /dev/null 2> /dev/null ++if test $? = 0; then ++ ldd_version=`ldd --version 2>&1 | head -1 | cut -f1 -d' '` ++ if [ x"${ldd_version}" = x"musl" ]; then ++ OUT=`echo $OUT | sed 's/-gnu/-musl/'` ++ fi ++fi ++ + # Test and fix solaris on x86_64 + echo $OUT | grep i386-pc-solaris > /dev/null 2> /dev/null + if test $? = 0; then +diff --git a/common/autoconf/build-aux/config.sub b/common/autoconf/build-aux/config.sub +index cc958da946..a665b00fcc 100644 +--- a/common/autoconf/build-aux/config.sub ++++ b/common/autoconf/build-aux/config.sub +@@ -29,6 +29,11 @@ + + DIR=`dirname $0` + ++if echo $* | grep linux-musl >/dev/null ; then ++ echo $* ++ exit ++fi ++ + # First, filter out everything that doesn't begin with "aarch64-" + if ! echo $* | grep '^aarch64-' >/dev/null ; then + . $DIR/autoconf-config.sub "$@" +diff --git a/common/autoconf/flags.m4 b/common/autoconf/flags.m4 +index 5d1ef8732f..006067fa73 100644 +--- a/common/autoconf/flags.m4 ++++ b/common/autoconf/flags.m4 +@@ -450,15 +450,21 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], + AC_ARG_WITH(extra-asflags, [AS_HELP_STRING([--with-extra-asflags], + [extra flags to be passed to the assembler])]) + +- CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags" +- CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags" ++ # Define MUSL_LIBC ++ DEFINE_LIBC="" ++ if test "x$OPENJDK_TARGET_LIBC" = xmusl; then ++ DEFINE_LIBC="-DMUSL_LIBC" ++ fi ++ ++ CFLAGS_JDK="${CFLAGS_JDK} $with_extra_cflags ${DEFINE_LIBC}" ++ CXXFLAGS_JDK="${CXXFLAGS_JDK} $with_extra_cxxflags ${DEFINE_LIBC}" + LDFLAGS_JDK="${LDFLAGS_JDK} $with_extra_ldflags" + + # Hotspot needs these set in their legacy form +- LEGACY_HOST_CFLAGS="$LEGACY_HOST_CFLAGS $with_extra_cflags" +- LEGACY_TARGET_CFLAGS="$LEGACY_TARGET_CFLAGS $with_extra_cflags" +- LEGACY_HOST_CXXFLAGS="$LEGACY_HOST_CXXFLAGS $with_extra_cxxflags" +- LEGACY_TARGET_CXXFLAGS="$LEGACY_TARGET_CXXFLAGS $with_extra_cxxflags" ++ LEGACY_HOST_CFLAGS="$LEGACY_HOST_CFLAGS $with_extra_cflags ${DEFINE_LIBC}" ++ LEGACY_TARGET_CFLAGS="$LEGACY_TARGET_CFLAGS $with_extra_cflags ${DEFINE_LIBC}" ++ LEGACY_HOST_CXXFLAGS="$LEGACY_HOST_CXXFLAGS $with_extra_cxxflags ${DEFINE_LIBC}" ++ LEGACY_TARGET_CXXFLAGS="$LEGACY_TARGET_CXXFLAGS $with_extra_cxxflags ${DEFINE_LIBC}" + LEGACY_HOST_LDFLAGS="$LEGACY_HOST_LDFLAGS $with_extra_ldflags" + LEGACY_TARGET_LDFLAGS="$LEGACY_TARGET_LDFLAGS $with_extra_ldflags" + LEGACY_HOST_ASFLAGS="$with_extra_asflags" +diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 +index 18ba585209..e46cb823ef 100644 +--- a/common/autoconf/jdk-options.m4 ++++ b/common/autoconf/jdk-options.m4 +@@ -152,6 +152,9 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JVM_VARIANTS], + AC_SUBST(JVM_VARIANT_CORE) + + INCLUDE_SA=true ++ if test "x$OPENJDK_TARGET_LIBC" = xmusl; then ++ INCLUDE_SA=false ++ fi + if test "x$JVM_VARIANT_ZERO" = xtrue ; then + INCLUDE_SA=false + fi +@@ -539,6 +542,18 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_VERSION_NUMBERS], + AC_SUBST(MACOSX_BUNDLE_NAME_BASE) + AC_SUBST(MACOSX_BUNDLE_ID_BASE) + ++ # The company name, if any ++ AC_ARG_WITH(company-name, [AS_HELP_STRING([--with-company-name], ++ [Set company name.])]) ++ if test "x$with_company_name" = xyes; then ++ AC_MSG_ERROR([--with-company-name must have a value]) ++ elif [ ! [[ $with_company_name =~ ^[[:print:]]*$ ]] ]; then ++ AC_MSG_ERROR([--with-company-name contains non-printing characters: $with_company_name]) ++ elif test "x$with_company_name" != x; then ++ COMPANY_NAME="$with_company_name" ++ fi ++ AC_SUBST(COMPANY_NAME) ++ + # The vendor name, if any + AC_ARG_WITH(vendor-name, [AS_HELP_STRING([--with-vendor-name], + [Set vendor name. Among others, used to set the 'java.vendor' +diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4 +index 99c7820224..f83d920e69 100644 +--- a/common/autoconf/platform.m4 ++++ b/common/autoconf/platform.m4 +@@ -161,6 +161,24 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS], + esac + ]) + ++# Support macro for PLATFORM_EXTRACT_TARGET_AND_BUILD. ++# Converts autoconf style OS name to OpenJDK style, into ++# VAR_LIBC. ++AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_LIBC], ++[ ++ case "$1" in ++ *linux*-musl) ++ VAR_LIBC=musl ++ ;; ++ *linux*-gnu) ++ VAR_LIBC=gnu ++ ;; ++ *) ++ VAR_LIBC=default ++ ;; ++ esac ++]) ++ + # Expects $host_os $host_cpu $build_os and $build_cpu + # and $with_target_bits to have been setup! + # +@@ -178,9 +196,10 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD], + AC_SUBST(OPENJDK_TARGET_AUTOCONF_NAME) + AC_SUBST(OPENJDK_BUILD_AUTOCONF_NAME) + +- # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables. ++ # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU/LIBC variables. + PLATFORM_EXTRACT_VARS_FROM_OS($build_os) + PLATFORM_EXTRACT_VARS_FROM_CPU($build_cpu) ++ PLATFORM_EXTRACT_VARS_FROM_LIBC($build_os) + # ..and setup our own variables. (Do this explicitely to facilitate searching) + OPENJDK_BUILD_OS="$VAR_OS" + OPENJDK_BUILD_OS_API="$VAR_OS_API" +@@ -189,6 +208,7 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD], + OPENJDK_BUILD_CPU_ARCH="$VAR_CPU_ARCH" + OPENJDK_BUILD_CPU_BITS="$VAR_CPU_BITS" + OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN" ++ OPENJDK_BUILD_LIBC="$VAR_LIBC" + AC_SUBST(OPENJDK_BUILD_OS) + AC_SUBST(OPENJDK_BUILD_OS_API) + AC_SUBST(OPENJDK_BUILD_OS_ENV) +@@ -196,13 +216,20 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD], + AC_SUBST(OPENJDK_BUILD_CPU_ARCH) + AC_SUBST(OPENJDK_BUILD_CPU_BITS) + AC_SUBST(OPENJDK_BUILD_CPU_ENDIAN) ++ AC_SUBST(OPENJDK_BUILD_LIBC) + + AC_MSG_CHECKING([openjdk-build os-cpu]) + AC_MSG_RESULT([$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU]) + +- # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU variables. ++ if test "x$OPENJDK_BUILD_OS" = "xlinux"; then ++ AC_MSG_CHECKING([openjdk-build C library]) ++ AC_MSG_RESULT([$OPENJDK_BUILD_LIBC]) ++ fi ++ ++ # Convert the autoconf OS/CPU value to our own data, into the VAR_OS/CPU/LIBC variables. + PLATFORM_EXTRACT_VARS_FROM_OS($host_os) + PLATFORM_EXTRACT_VARS_FROM_CPU($host_cpu) ++ PLATFORM_EXTRACT_VARS_FROM_LIBC($host_os) + # ... and setup our own variables. (Do this explicitely to facilitate searching) + OPENJDK_TARGET_OS="$VAR_OS" + OPENJDK_TARGET_OS_API="$VAR_OS_API" +@@ -211,6 +238,7 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD], + OPENJDK_TARGET_CPU_ARCH="$VAR_CPU_ARCH" + OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS" + OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN" ++ OPENJDK_TARGET_LIBC="$VAR_LIBC" + AC_SUBST(OPENJDK_TARGET_OS) + AC_SUBST(OPENJDK_TARGET_OS_API) + AC_SUBST(OPENJDK_TARGET_OS_ENV) +@@ -218,9 +246,15 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD], + AC_SUBST(OPENJDK_TARGET_CPU_ARCH) + AC_SUBST(OPENJDK_TARGET_CPU_BITS) + AC_SUBST(OPENJDK_TARGET_CPU_ENDIAN) ++ AC_SUBST(OPENJDK_TARGET_LIBC) + + AC_MSG_CHECKING([openjdk-target os-cpu]) + AC_MSG_RESULT([$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU]) ++ ++ if test "x$OPENJDK_TARGET_OS" = "xlinux"; then ++ AC_MSG_CHECKING([openjdk-target C library]) ++ AC_MSG_RESULT([$OPENJDK_TARGET_LIBC]) ++ fi + ]) + + # Check if a reduced build (32-bit on 64-bit platforms) is requested, and modify behaviour +diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in +index ea4ec8e125..a1eacaeb5a 100644 +--- a/common/autoconf/spec.gmk.in ++++ b/common/autoconf/spec.gmk.in +@@ -85,6 +85,8 @@ OPENJDK_TARGET_CPU_ARCH:=@OPENJDK_TARGET_CPU_ARCH@ + OPENJDK_TARGET_CPU_BITS:=@OPENJDK_TARGET_CPU_BITS@ + OPENJDK_TARGET_CPU_ENDIAN:=@OPENJDK_TARGET_CPU_ENDIAN@ + ++OPENJDK_TARGET_LIBC:=@OPENJDK_TARGET_LIBC@ ++ + COMPILE_TYPE:=@COMPILE_TYPE@ + + # Legacy support +@@ -108,6 +110,8 @@ OPENJDK_BUILD_CPU_ARCH:=@OPENJDK_BUILD_CPU_ARCH@ + OPENJDK_BUILD_CPU_BITS:=@OPENJDK_BUILD_CPU_BITS@ + OPENJDK_BUILD_CPU_ENDIAN:=@OPENJDK_BUILD_CPU_ENDIAN@ + ++OPENJDK_BUILD_LIBC:=@OPENJDK_BUILD_LIBC@ ++ + # Legacy OS values for use in release file. + REQUIRED_OS_NAME:=@REQUIRED_OS_NAME@ + REQUIRED_OS_VERSION:=@REQUIRED_OS_VERSION@ +diff --git a/hotspot/make/linux/makefiles/defs.make b/hotspot/make/linux/makefiles/defs.make +index ec414639d2..5d05825300 100644 +--- a/hotspot/make/linux/makefiles/defs.make ++++ b/hotspot/make/linux/makefiles/defs.make +@@ -305,6 +305,9 @@ endif + + # Serviceability Binaries + # No SA Support for PPC, IA64, ARM or zero ++# or if thread_db.h missing (musl) ++ ++ifneq ($(wildcard /usr/include/thread_db.h),) + ADD_SA_BINARIES/x86 = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \ + $(EXPORT_LIB_DIR)/sa-jdi.jar + ADD_SA_BINARIES/sparc = $(EXPORT_JRE_LIB_ARCH_DIR)/libsaproc.$(LIBRARY_SUFFIX) \ +@@ -324,6 +327,11 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) + endif + endif + endif ++else ++ADD_SA_BINARIES/x86 = ++ADD_SA_BINARIES/sparc = ++ADD_SA_BINARIES/aarch64 = ++endif + ADD_SA_BINARIES/ppc = + ADD_SA_BINARIES/ia64 = + ADD_SA_BINARIES/arm = +diff --git a/hotspot/make/linux/makefiles/sa.make b/hotspot/make/linux/makefiles/sa.make +index cdcb16a1a3..8d2f31e7cb 100644 +--- a/hotspot/make/linux/makefiles/sa.make ++++ b/hotspot/make/linux/makefiles/sa.make +@@ -59,9 +59,11 @@ SA_PROPERTIES = $(SA_CLASSDIR)/sa.properties + + # if $(AGENT_DIR) does not exist, we don't build SA + # also, we don't build SA on Itanium or zero. ++# check for thread_db.h too (musl does not have it). + + all: +- if [ -d $(AGENT_DIR) -a "$(SRCARCH)" != "ia64" \ ++ if [ -d $(AGENT_DIR) -a -f /usr/include/thread_db.h \ ++ -a "$(SRCARCH)" != "ia64" \ + -a "$(SRCARCH)" != "zero" ] ; then \ + $(MAKE) -f sa.make $(GENERATED)/sa-jdi.jar; \ + fi +diff --git a/hotspot/make/linux/makefiles/saproc.make b/hotspot/make/linux/makefiles/saproc.make +index ffc0ec5ce5..732c7614d6 100644 +--- a/hotspot/make/linux/makefiles/saproc.make ++++ b/hotspot/make/linux/makefiles/saproc.make +@@ -66,12 +66,15 @@ endif + + # if $(AGENT_DIR) does not exist, we don't build SA + # also, we don't build SA on Itanium or zero. ++# check for thread_db.h too (musl does not have it). + ++ifneq ($(wildcard /usr/include/thread_db.h),) + ifneq ($(wildcard $(AGENT_DIR)),) + ifneq ($(filter-out ia64 zero,$(SRCARCH)),) + BUILDLIBSAPROC = $(LIBSAPROC) + endif + endif ++endif + + ifneq ($(ALT_SASRCDIR),) + ALT_SAINCDIR=-I$(ALT_SASRCDIR) -DALT_SASRCDIR +diff --git a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp +index f661847b66..d40548f680 100644 +--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp ++++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp +@@ -1243,7 +1243,11 @@ bool MacroAssembler::is_load_from_polling_page(int instruction, void* ucontext, + // the safepoing polling page. + ucontext_t* uc = (ucontext_t*) ucontext; + // Set polling address. ++#ifndef MUSL_LIBC + address addr = (address)uc->uc_mcontext.regs->gpr[ra] + (ssize_t)ds; ++#else ++ address addr = (address)uc->uc_mcontext.gp_regs[ra] + (ssize_t)ds; ++#endif + if (polling_address_ptr != NULL) { + *polling_address_ptr = addr; + } +@@ -1264,15 +1268,24 @@ bool MacroAssembler::is_memory_serialization(int instruction, JavaThread* thread + int rb = inv_rb_field(instruction); + + // look up content of ra and rb in ucontext ++#ifndef MUSL_LIBC + address ra_val=(address)uc->uc_mcontext.regs->gpr[ra]; + long rb_val=(long)uc->uc_mcontext.regs->gpr[rb]; ++#else ++ address ra_val=(address)uc->uc_mcontext.gp_regs[ra]; ++ long rb_val=(long)uc->uc_mcontext.gp_regs[rb]; ++#endif + return os::is_memory_serialize_page(thread, ra_val+rb_val); + } else if (is_stw(instruction) || is_stwu(instruction)) { + int ra = inv_ra_field(instruction); + int d1 = inv_d1_field(instruction); + + // look up content of ra in ucontext ++#ifndef MUSL_LIBC + address ra_val=(address)uc->uc_mcontext.regs->gpr[ra]; ++#else ++ address ra_val=(address)uc->uc_mcontext.gp_regs[ra]; ++#endif + return os::is_memory_serialize_page(thread, ra_val+d1); + } else { + return false; +@@ -1335,11 +1348,20 @@ address MacroAssembler::get_stack_bang_address(int instruction, void *ucontext) + || (is_stdu(instruction) && rs == 1)) { + int ds = inv_ds_field(instruction); + // return banged address ++#ifndef MUSL_LIBC + return ds+(address)uc->uc_mcontext.regs->gpr[ra]; ++#else ++ return ds+(address)uc->uc_mcontext.gp_regs[ra]; ++#endif + } else if (is_stdux(instruction) && rs == 1) { + int rb = inv_rb_field(instruction); ++#ifndef MUSL_LIBC + address sp = (address)uc->uc_mcontext.regs->gpr[1]; + long rb_val = (long)uc->uc_mcontext.regs->gpr[rb]; ++#else ++ address sp = (address)uc->uc_mcontext.gp_regs[1]; ++ long rb_val = (long)uc->uc_mcontext.gp_regs[rb]; ++#endif + return ra != 1 || rb_val >= 0 ? NULL // not a stack bang + : sp + rb_val; // banged address + } +diff --git a/hotspot/src/os/linux/vm/jvm_linux.cpp b/hotspot/src/os/linux/vm/jvm_linux.cpp +index ba84788a1b..c22281f7ca 100644 +--- a/hotspot/src/os/linux/vm/jvm_linux.cpp ++++ b/hotspot/src/os/linux/vm/jvm_linux.cpp +@@ -154,7 +154,9 @@ struct siglabel siglabels[] = { + #ifdef SIGSTKFLT + "STKFLT", SIGSTKFLT, /* Stack fault. */ + #endif ++#ifdef SIGCLD + "CLD", SIGCLD, /* Same as SIGCHLD (System V). */ ++#endif + "CHLD", SIGCHLD, /* Child status has changed (POSIX). */ + "CONT", SIGCONT, /* Continue (POSIX). */ + "STOP", SIGSTOP, /* Stop, unblockable (POSIX). */ +diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp +index 742e17d115..d9a9877970 100644 +--- a/hotspot/src/os/linux/vm/os_linux.cpp ++++ b/hotspot/src/os/linux/vm/os_linux.cpp +@@ -96,7 +96,6 @@ + # include + # include + # include +-# include + # include + # include + # include +@@ -104,6 +103,10 @@ + # include + # include + ++#ifndef MUSL_LIBC ++#include ++#endif ++ + PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC + + #ifndef _GNU_SOURCE +@@ -145,7 +148,7 @@ const int os::Linux::_vm_default_page_size = (8 * K); + bool os::Linux::_is_floating_stack = false; + bool os::Linux::_is_NPTL = false; + bool os::Linux::_supports_fast_thread_cpu_time = false; +-const char * os::Linux::_glibc_version = NULL; ++const char * os::Linux::_libc_version = NULL; + const char * os::Linux::_libpthread_version = NULL; + pthread_condattr_t os::Linux::_condattr[1]; + +@@ -585,6 +588,15 @@ void os::Linux::hotspot_sigmask(Thread* thread) { + // detecting pthread library + + void os::Linux::libpthread_init() { ++#ifdef MUSL_LIBC ++ // Hard code Alpine Linux supported musl compatible settings. ++ // confstr() from musl libc returns EINVAL for ++ // _CS_GNU_LIBC_VERSION and _CS_GNU_LIBPTHREAD_VERSION ++ os::Linux::set_libc_version("musl - unknown"); ++ os::Linux::set_libpthread_version("musl - unknown"); ++ os::Linux::set_is_NPTL(); ++ os::Linux::set_is_floating_stack(); ++#else + // Save glibc and pthread version strings. Note that _CS_GNU_LIBC_VERSION + // and _CS_GNU_LIBPTHREAD_VERSION are supported in glibc >= 2.3.2. Use a + // generic name for earlier versions. +@@ -600,13 +612,13 @@ void os::Linux::libpthread_init() { + if (n > 0) { + char *str = (char *)malloc(n, mtInternal); + confstr(_CS_GNU_LIBC_VERSION, str, n); +- os::Linux::set_glibc_version(str); ++ os::Linux::set_libc_version(str); + } else { + // _CS_GNU_LIBC_VERSION is not supported, try gnu_get_libc_version() + static char _gnu_libc_version[32]; + jio_snprintf(_gnu_libc_version, sizeof(_gnu_libc_version), + "glibc %s %s", gnu_get_libc_version(), gnu_get_libc_release()); +- os::Linux::set_glibc_version(_gnu_libc_version); ++ os::Linux::set_libc_version(_gnu_libc_version); + } + + n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, 0); +@@ -619,7 +631,7 @@ void os::Linux::libpthread_init() { + // So sysconf(_SC_THREAD_THREADS_MAX) will return a positive value. + // On the other hand, NPTL does not have such a limit, sysconf() + // will return -1 and errno is not changed. Check if it is really NPTL. +- if (strcmp(os::Linux::glibc_version(), "glibc 2.3.2") == 0 && ++ if (strcmp(os::Linux::libc_version(), "glibc 2.3.2") == 0 && + strstr(str, "NPTL") && + sysconf(_SC_THREAD_THREADS_MAX) > 0) { + free(str); +@@ -643,6 +655,7 @@ void os::Linux::libpthread_init() { + if (os::Linux::is_NPTL() || os::Linux::supports_variable_stack_size()) { + os::Linux::set_is_floating_stack(); + } ++#endif + } + + ///////////////////////////////////////////////////////////////////////////// +@@ -800,7 +813,7 @@ static void *java_start(Thread *thread) { + // processors with hyperthreading technology. + static int counter = 0; + int pid = os::current_process_id(); +- alloca(((pid ^ counter++) & 7) * 128); ++ void *tmp = alloca(((pid ^ counter++) & 7) * 128); + + ThreadLocalStorage::set_thread(thread); + +@@ -2295,7 +2308,7 @@ void os::Linux::print_distro_info(outputStream* st) { + void os::Linux::print_libversion_info(outputStream* st) { + // libc, pthread + st->print("libc:"); +- st->print("%s ", os::Linux::glibc_version()); ++ st->print("%s ", os::Linux::libc_version()); + st->print("%s ", os::Linux::libpthread_version()); + if (os::Linux::is_LinuxThreads()) { + st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed"); +@@ -3012,6 +3025,14 @@ extern "C" JNIEXPORT void numa_warn(int number, char *where, ...) { } + extern "C" JNIEXPORT void numa_error(char *where) { } + extern "C" JNIEXPORT int fork1() { return fork(); } + ++#ifdef MUSL_LIBC ++ // dlvsym is not a part of POSIX and musl libc doesn't implement it. ++ static void *dlvsym(void *handle, const char *name, const char *ver) ++ { ++ return dlsym(handle, name); ++ } ++#endif ++ + // Handle request to load libnuma symbol version 1.1 (API v1). If it fails + // load symbol from base version instead. + void* os::Linux::libnuma_dlsym(void* handle, const char *name) { +@@ -5037,7 +5058,8 @@ void os::Linux::check_signal_handler(int sig) { + } + + if (thisHandler != jvmHandler) { +- tty->print("Warning: %s handler ", exception_name(sig, buf, O_BUFLEN)); ++ if(exception_name(sig, buf, O_BUFLEN)) ++ tty->print("Warning: %s handler ", exception_name(sig, buf, O_BUFLEN)); + tty->print("expected:%s", get_signal_handler_name(jvmHandler, buf, O_BUFLEN)); + tty->print_cr(" found:%s", get_signal_handler_name(thisHandler, buf, O_BUFLEN)); + // No need to check this sig any longer +@@ -5227,7 +5249,7 @@ jint os::init_2(void) + Linux::libpthread_init(); + if (PrintMiscellaneous && (Verbose || WizardMode)) { + tty->print_cr("[HotSpot is running with %s, %s(%s)]\n", +- Linux::glibc_version(), Linux::libpthread_version(), ++ Linux::libc_version(), Linux::libpthread_version(), + Linux::is_floating_stack() ? "floating stack" : "fixed stack"); + } + +diff --git a/hotspot/src/os/linux/vm/os_linux.hpp b/hotspot/src/os/linux/vm/os_linux.hpp +index ed15777877..f47c2cb731 100644 +--- a/hotspot/src/os/linux/vm/os_linux.hpp ++++ b/hotspot/src/os/linux/vm/os_linux.hpp +@@ -62,7 +62,7 @@ class Linux { + static address _initial_thread_stack_bottom; + static uintptr_t _initial_thread_stack_size; + +- static const char *_glibc_version; ++ static const char *_libc_version; + static const char *_libpthread_version; + + static bool _is_floating_stack; +@@ -89,7 +89,7 @@ class Linux { + static int commit_memory_impl(char* addr, size_t bytes, + size_t alignment_hint, bool exec); + +- static void set_glibc_version(const char *s) { _glibc_version = s; } ++ static void set_libc_version(const char *s) { _libc_version = s; } + static void set_libpthread_version(const char *s) { _libpthread_version = s; } + + static bool supports_variable_stack_size(); +@@ -183,7 +183,7 @@ class Linux { + static bool chained_handler(int sig, siginfo_t* siginfo, void* context); + + // GNU libc and libpthread version strings +- static const char *glibc_version() { return _glibc_version; } ++ static const char *libc_version() { return _libc_version; } + static const char *libpthread_version() { return _libpthread_version; } + + // NPTL or LinuxThreads? +diff --git a/hotspot/src/os/linux/vm/os_linux.inline.hpp b/hotspot/src/os/linux/vm/os_linux.inline.hpp +index a23bd56313..80b977711e 100644 +--- a/hotspot/src/os/linux/vm/os_linux.inline.hpp ++++ b/hotspot/src/os/linux/vm/os_linux.inline.hpp +@@ -33,9 +33,14 @@ + + #include + #include +-#include + #include + ++#ifndef MUSL_LIBC ++#include ++#else ++#include ++#endif ++ + inline void* os::thread_local_storage_at(int index) { + return pthread_getspecific((pthread_key_t)index); + } +diff --git a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp +index db1cb10499..5623377727 100644 +--- a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp ++++ b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp +@@ -72,7 +72,12 @@ + # include + # include + # include +-# include ++ ++#ifndef MUSL_LIBC ++#include ++#else ++#include /* provides __u64 */ ++#endif + + #define REG_FP 29 + +diff --git a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp +index ffee3b5089..17c1aec161 100644 +--- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp ++++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp +@@ -75,6 +75,9 @@ + # include + # include + ++#ifdef MUSL_LIBC ++#include ++#endif + + address os::current_stack_pointer() { + intptr_t* csp; +@@ -110,11 +113,19 @@ address os::Linux::ucontext_get_pc(ucontext_t * uc) { + // it because the volatile registers are not needed to make setcontext() work. + // Hopefully it was zero'd out beforehand. + guarantee(uc->uc_mcontext.regs != NULL, "only use ucontext_get_pc in sigaction context"); ++#ifndef MUSL_LIBC + return (address)uc->uc_mcontext.regs->nip; ++#else ++ return (address)uc->uc_mcontext.gp_regs[PT_NIP]; ++#endif + } + + intptr_t* os::Linux::ucontext_get_sp(ucontext_t * uc) { ++#ifndef MUSL_LIBC + return (intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/]; ++#else ++ return (intptr_t*)uc->uc_mcontext.gp_regs[1/*REG_SP*/]; ++#endif + } + + intptr_t* os::Linux::ucontext_get_fp(ucontext_t * uc) { +@@ -217,7 +228,11 @@ JVM_handle_linux_signal(int sig, + if ((sig == SIGSEGV || sig == SIGBUS) && uc) { + address const pc = os::Linux::ucontext_get_pc(uc); + if (pc && StubRoutines::is_safefetch_fault(pc)) { ++#ifndef MUSL_LIBC + uc->uc_mcontext.regs->nip = (unsigned long)StubRoutines::continuation_for_safefetch_fault(pc); ++#else ++ uc->uc_mcontext.gp_regs[PT_NIP] = (unsigned long)StubRoutines::continuation_for_safefetch_fault(pc); ++#endif + return true; + } + } +@@ -368,7 +383,11 @@ JVM_handle_linux_signal(int sig, + // continue at the next instruction after the faulting read. Returning + // garbage from this read is ok. + thread->set_pending_unsafe_access_error(); ++#ifndef MUSL_LIBC + uc->uc_mcontext.regs->nip = ((unsigned long)pc) + 4; ++#else ++ uc->uc_mcontext.gp_regs[PT_NIP] = ((unsigned long)pc) + 4; ++#endif + return true; + } + } +@@ -387,7 +406,11 @@ JVM_handle_linux_signal(int sig, + // continue at the next instruction after the faulting read. Returning + // garbage from this read is ok. + thread->set_pending_unsafe_access_error(); ++#ifndef MUSL_LIBC + uc->uc_mcontext.regs->nip = ((unsigned long)pc) + 4; ++#else ++ uc->uc_mcontext.gp_regs[PT_NIP] = ((unsigned long)pc) + 4; ++#endif + return true; + } + } +@@ -410,7 +433,11 @@ JVM_handle_linux_signal(int sig, + if (stub != NULL) { + // Save all thread context in case we need to restore it. + if (thread != NULL) thread->set_saved_exception_pc(pc); ++#ifndef MUSL_LIBC + uc->uc_mcontext.regs->nip = (unsigned long)stub; ++#else ++ uc->uc_mcontext.gp_regs[PT_NIP] = (unsigned long)stub; ++#endif + return true; + } + +@@ -568,6 +595,7 @@ void os::print_context(outputStream *st, void *context) { + ucontext_t* uc = (ucontext_t*)context; + + st->print_cr("Registers:"); ++#ifndef MUSL_LIBC + st->print("pc =" INTPTR_FORMAT " ", uc->uc_mcontext.regs->nip); + st->print("lr =" INTPTR_FORMAT " ", uc->uc_mcontext.regs->link); + st->print("ctr=" INTPTR_FORMAT " ", uc->uc_mcontext.regs->ctr); +@@ -576,6 +604,16 @@ void os::print_context(outputStream *st, void *context) { + st->print("r%-2d=" INTPTR_FORMAT " ", i, uc->uc_mcontext.regs->gpr[i]); + if (i % 3 == 2) st->cr(); + } ++#else // Musl ++ st->print("pc =" INTPTR_FORMAT " ", uc->uc_mcontext.gp_regs[PT_NIP]); ++ st->print("lr =" INTPTR_FORMAT " ", uc->uc_mcontext.gp_regs[PT_LNK]); ++ st->print("ctr=" INTPTR_FORMAT " ", uc->uc_mcontext.gp_regs[PT_CTR]); ++ st->cr(); ++ for (int i = 0; i < 32; i++) { ++ st->print("r%-2d=" INTPTR_FORMAT " ", i, uc->uc_mcontext.gp_regs[i]); ++ if (i % 3 == 2) st->cr(); ++ } ++#endif + st->cr(); + st->cr(); + +@@ -604,7 +642,11 @@ void os::print_register_info(outputStream *st, void *context) { + // this is only for the "general purpose" registers + for (int i = 0; i < 32; i++) { + st->print("r%-2d=", i); ++#ifndef MUSL_LIBC + print_location(st, uc->uc_mcontext.regs->gpr[i]); ++#else ++ print_location(st, uc->uc_mcontext.gp_regs[i]); ++#endif + } + st->cr(); + } +diff --git a/hotspot/src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp b/hotspot/src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp +index 802677f470..dd68a34549 100644 +--- a/hotspot/src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp ++++ b/hotspot/src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp +@@ -27,6 +27,10 @@ + #include "runtime/frame.inline.hpp" + #include "runtime/thread.hpp" + ++#ifdef MUSL_LIBC ++#include ++#endif ++ + bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, bool isInJava) { + assert(this->is_Java_thread(), "must be JavaThread"); + +@@ -42,8 +46,13 @@ bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, + // if we were running Java code when SIGPROF came in. + if (isInJava) { + ucontext_t* uc = (ucontext_t*) ucontext; ++#ifndef MUSL_LIBC + frame ret_frame((intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/], + (address)uc->uc_mcontext.regs->nip); ++#else ++ frame ret_frame((intptr_t*)uc->uc_mcontext.gp_regs[1/*REG_SP*/], ++ (address)uc->uc_mcontext.gp_regs[PT_NIP]); ++#endif + + if (ret_frame.pc() == NULL) { + // ucontext wasn't useful +@@ -56,7 +65,11 @@ bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, + if (m == NULL || !m->is_valid_method()) return false; + if (!Metaspace::contains((const void*)m)) return false; + ++#ifndef MUSL_LIBC + uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/]; ++#else ++ uint64_t reg_bcp = uc->uc_mcontext.gp_regs[14/*R14_bcp*/]; ++#endif + uint64_t istate_bcp = istate->bcp; + uint64_t code_start = (uint64_t)(m->code_base()); + uint64_t code_end = (uint64_t)(m->code_base() + m->code_size()); +diff --git a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp +index 12b5ca0acd..b489fc89be 100644 +--- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp ++++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp +@@ -72,7 +72,10 @@ + # include + # include + # include +-# include ++ ++#ifndef MUSL_LIBC ++#include ++#endif + + #ifdef AMD64 + #define REG_SP REG_RSP +@@ -544,6 +547,11 @@ JVM_handle_linux_signal(int sig, + return true; // Mute compiler + } + ++#ifdef MUSL_LIBC ++#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw)) ++#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw)) ++#endif ++ + void os::Linux::init_thread_fpu_state(void) { + #ifndef AMD64 + // set fpu to 53 bit precision +diff --git a/hotspot/src/os_cpu/linux_x86/vm/threadLS_linux_x86.hpp b/hotspot/src/os_cpu/linux_x86/vm/threadLS_linux_x86.hpp +index f3f2f26f88..00b472693a 100644 +--- a/hotspot/src/os_cpu/linux_x86/vm/threadLS_linux_x86.hpp ++++ b/hotspot/src/os_cpu/linux_x86/vm/threadLS_linux_x86.hpp +@@ -32,7 +32,9 @@ + // map stack pointer to thread pointer - see notes in threadLS_linux_x86.cpp + #define SP_BITLENGTH 32 + #define PAGE_SHIFT 12 ++ #if !defined(MUSL_LIBC) || !defined(PAGE_SIZE) + #define PAGE_SIZE (1UL << PAGE_SHIFT) ++ #endif + static Thread* _sp_map[1UL << (SP_BITLENGTH - PAGE_SHIFT)]; + + public: +diff --git a/jdk/make/gensrc/GensrcMisc.gmk b/jdk/make/gensrc/GensrcMisc.gmk +index 0e3dee5ca3..fc19b082cc 100644 +--- a/jdk/make/gensrc/GensrcMisc.gmk ++++ b/jdk/make/gensrc/GensrcMisc.gmk +@@ -30,6 +30,11 @@ include ProfileNames.gmk + # string and the runtime name into the Version.java file. + # To be printed by java -version + ++company_name = ++ifneq ($(COMPANY_NAME),N/A) ++ company_name=($(COMPANY_NAME)) ++endif ++ + $(JDK_OUTPUTDIR)/gensrc/sun/misc/Version.java \ + $(PROFILE_VERSION_JAVA_TARGETS): \ + $(JDK_TOPDIR)/src/share/classes/sun/misc/Version.java.template +@@ -41,6 +46,7 @@ $(PROFILE_VERSION_JAVA_TARGETS): \ + -e 's/@@java_runtime_version@@/$(FULL_VERSION)/g' \ + -e 's/@@java_runtime_name@@/$(RUNTIME_NAME)/g' \ + -e 's/@@java_profile_name@@/$(call profile_version_name, $@)/g' \ ++ -e 's/@@company_name@@/$(company_name)/g' \ + $< > $@.tmp + $(MV) $@.tmp $@ + +diff --git a/jdk/src/aix/native/java/net/aix_close.c b/jdk/src/aix/native/java/net/aix_close.c +index 5bf798aba1..b6696631a0 100644 +--- a/jdk/src/aix/native/java/net/aix_close.c ++++ b/jdk/src/aix/native/java/net/aix_close.c +@@ -54,7 +54,11 @@ + #include + #include + ++#ifndef MUSL_LIBC + #include ++#else ++#include ++#endif + #include "jvm.h" + + /* +diff --git a/jdk/src/aix/native/sun/nio/ch/AixNativeThread.c b/jdk/src/aix/native/sun/nio/ch/AixNativeThread.c +index c0d5857962..66098cc36d 100644 +--- a/jdk/src/aix/native/sun/nio/ch/AixNativeThread.c ++++ b/jdk/src/aix/native/sun/nio/ch/AixNativeThread.c +@@ -32,7 +32,12 @@ + #include "sun_nio_ch_NativeThread.h" + + #include ++ ++#ifndef MUSL_LIBC + #include ++#else ++#include ++#endif + + /* Also defined in src/aix/native/java/net/aix_close.c */ + #define INTERRUPT_SIGNAL (SIGRTMAX - 1) +diff --git a/jdk/src/aix/native/sun/nio/ch/AixPollPort.c b/jdk/src/aix/native/sun/nio/ch/AixPollPort.c +index 70064b890e..c0466dcc9f 100644 +--- a/jdk/src/aix/native/sun/nio/ch/AixPollPort.c ++++ b/jdk/src/aix/native/sun/nio/ch/AixPollPort.c +@@ -34,13 +34,18 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + ++#ifndef MUSL_LIBC ++#include ++#else ++#include ++#endif ++ + /* Initially copied from src/solaris/native/sun/nio/ch/nio_util.h */ + #define RESTARTABLE(_cmd, _result) do { \ + do { \ +diff --git a/jdk/src/macosx/javavm/export/jvm_md.h b/jdk/src/macosx/javavm/export/jvm_md.h +index 012bb1babe..592bfb5ab9 100644 +--- a/jdk/src/macosx/javavm/export/jvm_md.h ++++ b/jdk/src/macosx/javavm/export/jvm_md.h +@@ -60,7 +60,12 @@ + #include + #include + #include ++ ++#ifndef MUSL_LIBC + #include ++#else ++#include ++#endif + + /* O Flags */ + +diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp b/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp +index f58c94956c..0afbf6bb98 100644 +--- a/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp ++++ b/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp +@@ -46,6 +46,10 @@ + + #include "zip.h" + ++#ifdef MUSL_LIBC ++#define uchar unsigned char ++#endif ++ + #ifdef NO_ZLIB + + inline bool jar::deflate_bytes(bytes& head, bytes& tail) { +diff --git a/jdk/src/share/native/com/sun/java/util/jar/pack/zip.h b/jdk/src/share/native/com/sun/java/util/jar/pack/zip.h +index 14ffc9d65b..4137714f7d 100644 +--- a/jdk/src/share/native/com/sun/java/util/jar/pack/zip.h ++++ b/jdk/src/share/native/com/sun/java/util/jar/pack/zip.h +@@ -23,9 +23,13 @@ + * questions. + */ + ++#ifndef MUSL_LIBC + #define ushort unsigned short + #define uint unsigned int + #define uchar unsigned char ++#else ++#include ++#endif + + struct unpacker; + +diff --git a/jdk/src/share/native/java/lang/System.c b/jdk/src/share/native/java/lang/System.c +index 04ef657465..b06a38f87e 100644 +--- a/jdk/src/share/native/java/lang/System.c ++++ b/jdk/src/share/native/java/lang/System.c +@@ -110,13 +110,13 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x) + + /* Third party may overwrite these values. */ + #ifndef VENDOR +-#define VENDOR "Oracle Corporation" ++#define VENDOR "Eclipse Foundation" + #endif + #ifndef VENDOR_URL +-#define VENDOR_URL "http://java.oracle.com/" ++#define VENDOR_URL "https://adoptium.net/" + #endif + #ifndef VENDOR_URL_BUG +-#define VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/" ++#define VENDOR_URL_BUG "https://github.com/adoptium/adoptium-support/issues" + #endif + + #define JAVA_MAX_SUPPORTED_VERSION 52 +diff --git a/jdk/src/share/native/sun/awt/medialib/mlib_types.h b/jdk/src/share/native/sun/awt/medialib/mlib_types.h +index aba0394ffd..ad548aef64 100644 +--- a/jdk/src/share/native/sun/awt/medialib/mlib_types.h ++++ b/jdk/src/share/native/sun/awt/medialib/mlib_types.h +@@ -27,6 +27,10 @@ + #ifndef MLIB_TYPES_H + #define MLIB_TYPES_H + ++#ifdef MUSL_LIBC ++#include /* for NULL */ ++#endif ++ + #include + #if defined(_MSC_VER) + #include /* for FLT_MAX and DBL_MAX */ +diff --git a/jdk/src/solaris/bin/java_md_solinux.c b/jdk/src/solaris/bin/java_md_solinux.c +index e5056c44a7..58d3d7492a 100644 +--- a/jdk/src/solaris/bin/java_md_solinux.c ++++ b/jdk/src/solaris/bin/java_md_solinux.c +@@ -292,6 +292,10 @@ RequiresSetenv(int wanted, const char *jvmpath) { + char *dmllp = NULL; + char *p; /* a utility pointer */ + ++#ifdef MUSL_LIBC ++ return JNI_TRUE; ++#endif ++ + #ifdef AIX + /* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */ + return JNI_TRUE; +diff --git a/jdk/src/solaris/javavm/export/jvm_md.h b/jdk/src/solaris/javavm/export/jvm_md.h +index 5c681914bb..a181456010 100644 +--- a/jdk/src/solaris/javavm/export/jvm_md.h ++++ b/jdk/src/solaris/javavm/export/jvm_md.h +@@ -65,7 +65,12 @@ + #include + #include + #include ++ ++#ifndef MUSL_LIBC + #include ++#else ++#include ++#endif + + /* O Flags */ + +diff --git a/jdk/src/solaris/native/java/lang/UNIXProcess_md.c b/jdk/src/solaris/native/java/lang/UNIXProcess_md.c +index 9b510ad3a9..ad233a2a76 100644 +--- a/jdk/src/solaris/native/java/lang/UNIXProcess_md.c ++++ b/jdk/src/solaris/native/java/lang/UNIXProcess_md.c +@@ -550,7 +550,11 @@ static pid_t + startChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) { + switch (c->mode) { + case MODE_VFORK: ++// use regular fork when running on musl ++// this should fix deadlocks on aarch64 ++#ifndef MUSL_LIBC + return vforkChild(c); ++#endif + case MODE_FORK: + return forkChild(c); + #if defined(__solaris__) || defined(_ALLBSD_SOURCE) || defined(_AIX) +@@ -649,8 +653,12 @@ Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env, + if (resultPid < 0) { + switch (c->mode) { + case MODE_VFORK: ++// use regular fork when running on musl ++// this should fix deadlocks on aarch64 ++#ifndef MUSL_LIBC + throwIOException(env, errno, "vfork failed"); + break; ++#endif + case MODE_FORK: + throwIOException(env, errno, "fork failed"); + break; +diff --git a/jdk/src/solaris/native/java/lang/childproc.c b/jdk/src/solaris/native/java/lang/childproc.c +index c0045d5371..2d20db6185 100644 +--- a/jdk/src/solaris/native/java/lang/childproc.c ++++ b/jdk/src/solaris/native/java/lang/childproc.c +@@ -23,7 +23,6 @@ + * questions. + */ + +-#include + #include + #include + #include +@@ -31,6 +30,12 @@ + #include + #include + ++#ifndef MUSL_LIBC ++#include ++#else ++#include ++#endif ++ + #include "childproc.h" + + const char * const *parentPathv; +@@ -57,6 +62,8 @@ closeSafely(int fd) + return (fd == -1) ? 0 : close(fd); + } + ++#ifndef MUSL_LIBC ++ + int + isAsciiDigit(char c) + { +@@ -115,6 +122,54 @@ closeDescriptors(void) + return 1; + } + ++#else // Musl ++ ++int ++closeDescriptors(void) ++{ ++ int from_fd = FAIL_FILENO + 1; ++ struct pollfd pfds[1024]; ++ int i, total, nclosed = 0; ++ int max_fd = sysconf(_SC_OPEN_MAX); ++ ++ if (max_fd < 0) ++ return 0; ++ ++ /* init events */ ++ total = max_fd - from_fd; ++ for (i = 0; i < (total < 1024 ? total : 1024); i++) { ++ pfds[i].events = 0; ++ } ++ ++ while (from_fd < max_fd) { ++ int nfds, r = 0; ++ ++ total = max_fd - from_fd; ++ nfds = total < 1024 ? total : 1024; ++ ++ for (i = 0; i < nfds; i++) ++ pfds[i].fd = from_fd + i; ++ ++ do { ++ r = poll(pfds, nfds, 0); ++ } while (r == -1 && errno == EINTR); ++ ++ if (r < 0) ++ return 0; ++ ++ ++ for (i = 0; i < nfds; i++) ++ if (pfds[i].revents != POLLNVAL) { ++ nclosed++; ++ close(pfds[i].fd); ++ } ++ from_fd += nfds; ++ } ++ return 1; ++} ++ ++#endif ++ + int + moveDescriptor(int fd_from, int fd_to) + { +diff --git a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c +index 8b2e3cdce9..6a4a513c0d 100644 +--- a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c ++++ b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c +@@ -47,7 +47,7 @@ + + #include "java_net_Inet4AddressImpl.h" + +-#if defined(__GLIBC__) || (defined(__FreeBSD__) && (__FreeBSD_version >= 601104)) ++#if defined(__linux__) || (defined(__FreeBSD__) && (__FreeBSD_version >= 601104)) + #define HAS_GLIBC_GETHOSTBY_R 1 + #endif + +diff --git a/jdk/src/solaris/native/java/net/bsd_close.c b/jdk/src/solaris/native/java/net/bsd_close.c +index a6050e1f9a..e77f973443 100644 +--- a/jdk/src/solaris/native/java/net/bsd_close.c ++++ b/jdk/src/solaris/native/java/net/bsd_close.c +@@ -38,7 +38,12 @@ + #include + #include + #include ++ ++#ifndef MUSL_LIBC + #include ++#else ++#include ++#endif + #include "jvm.h" + + /* +diff --git a/jdk/src/solaris/native/java/net/linux_close.c b/jdk/src/solaris/native/java/net/linux_close.c +index c7a148c746..327cc7ac5b 100644 +--- a/jdk/src/solaris/native/java/net/linux_close.c ++++ b/jdk/src/solaris/native/java/net/linux_close.c +@@ -36,7 +36,12 @@ + #include + #include + #include ++ ++#ifndef MUSL_LIBC + #include ++#else ++#include ++#endif + #include "jvm.h" + + /* +@@ -59,7 +64,7 @@ typedef struct { + /* + * Signal to unblock thread + */ +-static int sigWakeup = (__SIGRTMAX - 2); ++static int sigWakeup; + + /* + * fdTable holds one entry per file descriptor, up to a certain +@@ -148,6 +153,9 @@ static void __attribute((constructor)) init() { + /* + * Setup the signal handler + */ ++#ifndef _AIX ++ sigWakeup = SIGRTMAX - 2; ++#endif + sa.sa_handler = sig_wakeup; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); +diff --git a/jdk/src/solaris/native/java/net/net_util_md.c b/jdk/src/solaris/native/java/net/net_util_md.c +index bd0bd8c2c9..4c021aea4d 100644 +--- a/jdk/src/solaris/native/java/net/net_util_md.c ++++ b/jdk/src/solaris/native/java/net/net_util_md.c +@@ -662,7 +662,7 @@ struct localinterface { + + static struct localinterface *localifs = 0; + static int localifsSize = 0; /* size of array */ +-static int nifs = 0; /* number of entries used in array */ ++static int nifs = -1; /* number of entries used in array */ + + /* not thread safe: make sure called once from one thread */ + +@@ -674,6 +674,10 @@ static void initLocalIfs () { + int index, x1, x2, x3; + unsigned int u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,ua,ub,uc,ud,ue,uf; + ++ if (nifs >= 0) ++ return ; ++ nifs = 0; ++ + if ((f = fopen("/proc/net/if_inet6", "r")) == NULL) { + return ; + } +@@ -702,7 +706,7 @@ static void initLocalIfs () { + localifs = (struct localinterface *) realloc ( + localifs, sizeof (struct localinterface)* (localifsSize+5)); + if (localifs == 0) { +- nifs = 0; ++ nifs = -1; + fclose (f); + return; + } +@@ -725,9 +729,7 @@ static void initLocalIfs () { + static int getLocalScopeID (char *addr) { + struct localinterface *lif; + int i; +- if (localifs == 0) { +- initLocalIfs(); +- } ++ initLocalIfs(); + for (i=0, lif=localifs; ilocaladdr, 16) == 0) { + return lif->index; +diff --git a/jdk/src/solaris/native/java/net/net_util_md.h b/jdk/src/solaris/native/java/net/net_util_md.h +index a48446de9c..d0b61a6ba1 100644 +--- a/jdk/src/solaris/native/java/net/net_util_md.h ++++ b/jdk/src/solaris/native/java/net/net_util_md.h +@@ -33,7 +33,11 @@ + #include + + #ifndef USE_SELECT +-#include ++#ifndef MUSL_LIBC ++ #include ++#else ++ #include ++#endif + #endif + + +diff --git a/jdk/src/solaris/native/sun/nio/ch/DevPollArrayWrapper.c b/jdk/src/solaris/native/sun/nio/ch/DevPollArrayWrapper.c +index 6860a167bb..b581508cf4 100644 +--- a/jdk/src/solaris/native/sun/nio/ch/DevPollArrayWrapper.c ++++ b/jdk/src/solaris/native/sun/nio/ch/DevPollArrayWrapper.c +@@ -28,10 +28,15 @@ + #include "jvm.h" + #include "jlong.h" + #include "sun_nio_ch_DevPollArrayWrapper.h" +-#include + #include + #include + ++#ifndef MUSL_LIBC ++#include ++#else ++#include ++#endif ++ + #ifdef __cplusplus + extern "C" { + #endif +diff --git a/jdk/src/solaris/native/sun/nio/ch/NativeThread.c b/jdk/src/solaris/native/sun/nio/ch/NativeThread.c +index 5e2a78b7af..b512b10aed 100644 +--- a/jdk/src/solaris/native/sun/nio/ch/NativeThread.c ++++ b/jdk/src/solaris/native/sun/nio/ch/NativeThread.c +@@ -34,9 +34,13 @@ + + #ifdef __linux__ + #include +- #include ++ #ifndef MUSL_LIBC ++ #include ++ #else ++ #include ++ #endif + /* Also defined in net/linux_close.c */ +- #define INTERRUPT_SIGNAL (__SIGRTMAX - 2) ++ #define INTERRUPT_SIGNAL (SIGRTMAX - 2) + #elif __solaris__ + #include + #include +diff --git a/jdk/src/solaris/native/sun/nio/ch/Net.c b/jdk/src/solaris/native/sun/nio/ch/Net.c +index fcb6197c1d..37f04646bd 100644 +--- a/jdk/src/solaris/native/sun/nio/ch/Net.c ++++ b/jdk/src/solaris/native/sun/nio/ch/Net.c +@@ -23,7 +23,12 @@ + * questions. + */ + ++#ifndef MUSL_LIBC + #include ++#else ++#include ++#endif ++ + #include + #include + #include +diff --git a/jdk/src/solaris/native/sun/nio/fs/LinuxWatchService.c b/jdk/src/solaris/native/sun/nio/fs/LinuxWatchService.c +index 375aaa4850..d2169095a2 100644 +--- a/jdk/src/solaris/native/sun/nio/fs/LinuxWatchService.c ++++ b/jdk/src/solaris/native/sun/nio/fs/LinuxWatchService.c +@@ -32,9 +32,14 @@ + #include + #include + #include +-#include + #include + ++#ifndef MUSL_LIBC ++#include ++#else ++#include ++#endif ++ + #include "sun_nio_fs_LinuxWatchService.h" + + static void throwUnixException(JNIEnv* env, int errnum) { +diff --git a/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c b/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c +index 6017308d0b..a583b4bae8 100644 +--- a/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c ++++ b/jdk/src/solaris/native/sun/tools/attach/LinuxVirtualMachine.c +@@ -195,6 +195,9 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_LinuxVirtualMachine_connect + JNIEXPORT jboolean JNICALL Java_sun_tools_attach_LinuxVirtualMachine_isLinuxThreads + (JNIEnv *env, jclass cls) + { ++# ifdef MUSL_LIBC ++ return JNI_FALSE; ++# else + # ifndef _CS_GNU_LIBPTHREAD_VERSION + # define _CS_GNU_LIBPTHREAD_VERSION 3 + # endif +@@ -222,6 +225,7 @@ JNIEXPORT jboolean JNICALL Java_sun_tools_attach_LinuxVirtualMachine_isLinuxThre + res = (jboolean)(strstr(s, "NPTL") == NULL); + free(s); + return res; ++# endif + } + + /* +diff --git a/jdk/src/solaris/native/sun/xawt/XToolkit.c b/jdk/src/solaris/native/sun/xawt/XToolkit.c +index 24557cba41..1123389585 100644 +--- a/jdk/src/solaris/native/sun/xawt/XToolkit.c ++++ b/jdk/src/solaris/native/sun/xawt/XToolkit.c +@@ -27,9 +27,6 @@ + #include + #include + #include +-#ifdef __linux__ +-#include +-#endif + + #include + #include +@@ -796,26 +793,6 @@ JNIEXPORT jstring JNICALL Java_sun_awt_X11_XToolkit_getEnv + return ret; + } + +-#ifdef __linux__ +-void print_stack(void) +-{ +- void *array[10]; +- size_t size; +- char **strings; +- size_t i; +- +- size = backtrace (array, 10); +- strings = backtrace_symbols (array, size); +- +- fprintf (stderr, "Obtained %zd stack frames.\n", size); +- +- for (i = 0; i < size; i++) +- fprintf (stderr, "%s\n", strings[i]); +- +- free (strings); +-} +-#endif +- + Window get_xawt_root_shell(JNIEnv *env) { + static jclass classXRootWindow = NULL; + static jmethodID methodGetXRootWindow = NULL; +diff --git a/jdk/src/solaris/transport/socket/socket_md.c b/jdk/src/solaris/transport/socket/socket_md.c +index 33e062e087..e4f6b56ad4 100644 +--- a/jdk/src/solaris/transport/socket/socket_md.c ++++ b/jdk/src/solaris/transport/socket/socket_md.c +@@ -34,10 +34,14 @@ + #include + #include + #ifdef __solaris__ +-#include ++ #include + #else +-#include +-#include ++ #include ++ #ifndef MUSL_LIBC ++ #include ++ #else ++ #include ++ #endif + #endif + + #include "socket_md.h" +-- +2.39.0 diff --git a/patches/alpine-jdk8u/actions-ignore-branches.patch b/patches/alpine-jdk8u/actions-ignore-branches.patch new file mode 100644 index 00000000..d1107174 --- /dev/null +++ b/patches/alpine-jdk8u/actions-ignore-branches.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Adoptium +Date: Mon, 17 Sep 2001 00:00:00 +0000 +Subject: [PATCH] skip github actions builds to save executors + +--- + .github/workflows/submit.yml | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/.github/workflows/submit.yml b/.github/workflows/submit.yml +index 72e619aa83..887a20c844 100644 +--- a/.github/workflows/submit.yml ++++ b/.github/workflows/submit.yml +@@ -4,6 +4,8 @@ on: + push: + branches-ignore: + - master ++ - dev* ++ - release* + - pr/* + workflow_dispatch: + inputs: +-- +2.39.0 diff --git a/patches/jdk11u/actions-ignore-branches.patch b/patches/jdk11u/actions-ignore-branches.patch new file mode 100644 index 00000000..e69de29b diff --git a/patches/jdk17u/actions-ignore-branches.patch b/patches/jdk17u/actions-ignore-branches.patch new file mode 100644 index 00000000..47ebe24c --- /dev/null +++ b/patches/jdk17u/actions-ignore-branches.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Adoptium +Date: Mon, 17 Sep 2001 00:00:00 +0000 +Subject: [PATCH] skip github actions builds to save executors + +--- + .github/workflows/main.yml | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml +index 4e1957194b9..416878cc4c9 100644 +--- a/.github/workflows/main.yml ++++ b/.github/workflows/main.yml +@@ -29,6 +29,8 @@ on: + push: + branches-ignore: + - master ++ - dev* ++ - release* + - pr/* + workflow_dispatch: + inputs: +-- +2.39.0 diff --git a/patches/jdk21u/actions-ignore-branches.patch b/patches/jdk21u/actions-ignore-branches.patch new file mode 100644 index 00000000..70255376 --- /dev/null +++ b/patches/jdk21u/actions-ignore-branches.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Adoptium +Date: Mon, 17 Sep 2001 00:00:00 +0000 +Subject: [PATCH] skip github actions builds to save executors + +--- + .github/workflows/main.yml | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml +index 5097d3e03488e90d582f8dfd2b7c147a4c342074..416878cc4c9 100644 +--- a/.github/workflows/main.yml ++++ b/.github/workflows/main.yml +@@ -29,6 +29,8 @@ on: + push: + branches-ignore: + - master ++ - dev* ++ - release* + - pr/* + workflow_dispatch: + inputs: +-- +2.39.0 diff --git a/patches/jdk8u/0001-Backport-8073139.patch b/patches/jdk8u/0001-Backport-8073139.patch deleted file mode 100644 index c185ede9..00000000 --- a/patches/jdk8u/0001-Backport-8073139.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 058ba9a0c163eeb4ae80d922a9102a4dbd5ccb0a Mon Sep 17 00:00:00 2001 -From: John Oliver -Date: Thu, 1 Nov 2018 14:05:55 +0000 -Subject: [PATCH] Backport 8073139 - ---- - common/autoconf/flags.m4 | 3 +++ - common/autoconf/jdk-options.m4 | 2 +- - 2 files changed, 4 insertions(+), 1 deletion(-) - -diff --git a/common/autoconf/flags.m4 b/common/autoconf/flags.m4 -index c586b7f..93dc715 100644 ---- a/common/autoconf/flags.m4 -+++ b/common/autoconf/flags.m4 -@@ -532,6 +532,9 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN" - fi - fi -+ if test "x$OPENJDK_TARGET_CPU" = xppc64le; then -+ CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DABI_ELFv2" -+ fi - - # Setup target OS define. Use OS target name but in upper case. - OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` -diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 -index 35e04f3..9e5f3c0 100644 ---- a/common/autoconf/jdk-options.m4 -+++ b/common/autoconf/jdk-options.m4 -@@ -158,7 +158,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JVM_VARIANTS], - if test "x$JVM_VARIANT_ZEROSHARK" = xtrue ; then - INCLUDE_SA=false - fi -- if test "x$VAR_CPU" = xppc64 ; then -+ if test "x$VAR_CPU" = xppc64 -o "x$VAR_CPU" = xppc64le ; then - INCLUDE_SA=false - fi - if test "x$OPENJDK_TARGET_CPU" = xaarch64; then --- -2.7.4 - diff --git a/patches/jdk8u/0001-Set-vendor-information.patch b/patches/jdk8u/0001-Set-vendor-information.patch index af00f6e8..0d2f8eb8 100644 --- a/patches/jdk8u/0001-Set-vendor-information.patch +++ b/patches/jdk8u/0001-Set-vendor-information.patch @@ -8,22 +8,25 @@ Subject: [PATCH] Set vendor information 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/native/java/lang/System.c b/jdk/src/share/native/java/lang/System.c -index 5c36460..92cd3df 100644 +index 04ef657465..b06a38f87e 100644 --- a/jdk/src/share/native/java/lang/System.c +++ b/jdk/src/share/native/java/lang/System.c -@@ -109,9 +109,9 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x) - } else ((void) 0) +@@ -110,13 +110,13 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x) - #ifndef VENDOR /* Third party may overwrite this. */ + /* Third party may overwrite these values. */ + #ifndef VENDOR -#define VENDOR "Oracle Corporation" --#define VENDOR_URL "http://java.oracle.com/" --#define VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/" +#define VENDOR "Eclipse Foundation" + #endif + #ifndef VENDOR_URL +-#define VENDOR_URL "http://java.oracle.com/" +#define VENDOR_URL "https://adoptium.net/" + #endif + #ifndef VENDOR_URL_BUG +-#define VENDOR_URL_BUG "http://bugreport.sun.com/bugreport/" +#define VENDOR_URL_BUG "https://github.com/adoptium/adoptium-support/issues" #endif #define JAVA_MAX_SUPPORTED_VERSION 52 -- 2.7.4 - diff --git a/patches/jdk8u/actions-ignore-branches.patch b/patches/jdk8u/actions-ignore-branches.patch new file mode 100644 index 00000000..d1107174 --- /dev/null +++ b/patches/jdk8u/actions-ignore-branches.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Adoptium +Date: Mon, 17 Sep 2001 00:00:00 +0000 +Subject: [PATCH] skip github actions builds to save executors + +--- + .github/workflows/submit.yml | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/.github/workflows/submit.yml b/.github/workflows/submit.yml +index 72e619aa83..887a20c844 100644 +--- a/.github/workflows/submit.yml ++++ b/.github/workflows/submit.yml +@@ -4,6 +4,8 @@ on: + push: + branches-ignore: + - master ++ - dev* ++ - release* + - pr/* + workflow_dispatch: + inputs: +-- +2.39.0 diff --git a/patches/jdk8u/company_name.patch b/patches/jdk8u/company_name.patch index da7f8163..2095e5df 100644 --- a/patches/jdk8u/company_name.patch +++ b/patches/jdk8u/company_name.patch @@ -4,139 +4,16 @@ Date: Thu, 30 Aug 2018 14:22:52 +0100 Subject: [PATCH] Allow setting company name --- - common/autoconf/autogen.sh | 0 - common/autoconf/generated-configure.sh | 35 +++++++++++++++++-- - common/autoconf/jdk-options.m4 | 13 ++++++- - configure | 0 - jdk/make/gensrc/GensrcMisc.gmk | 6 ++++ - .../classes/sun/misc/Version.java.template | 7 ++-- - 6 files changed, 55 insertions(+), 6 deletions(-) - mode change 100644 => 100755 common/autoconf/autogen.sh - mode change 100644 => 100755 configure + common/autoconf/jdk-options.m4 | 11 +++++++++++ + jdk/make/gensrc/GensrcMisc.gmk | 6 ++++++ + jdk/src/share/classes/sun/misc/Version.java.template | 7 +++++-- + 3 files changed, 22 insertions(+), 2 deletions(-) -diff --git a/common/autoconf/autogen.sh b/common/autoconf/autogen.sh -old mode 100644 -new mode 100755 -diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh -index c9992e4c8a..caf4963a93 100644 ---- a/common/autoconf/generated-configure.sh -+++ b/common/autoconf/generated-configure.sh -@@ -822,9 +822,9 @@ COOKED_BUILD_NUMBER - COOKED_JDK_UPDATE_VERSION - JDK_VERSION - COPYRIGHT_YEAR -+COMPANY_NAME - MACOSX_BUNDLE_ID_BASE - MACOSX_BUNDLE_NAME_BASE --COMPANY_NAME - JDK_RC_PLATFORM_NAME - PRODUCT_SUFFIX - PRODUCT_NAME -@@ -1004,6 +1004,7 @@ infodir - docdir - oldincludedir - includedir -+runstatedir - localstatedir - sharedstatedir - sysconfdir -@@ -1054,6 +1055,7 @@ with_milestone - with_update_version - with_user_release_suffix - with_build_number -+with_company_name - with_copyright_year - with_boot_jdk - with_boot_jdk_jvmargs -@@ -1237,6 +1239,7 @@ datadir='${datarootdir}' - sysconfdir='${prefix}/etc' - sharedstatedir='${prefix}/com' - localstatedir='${prefix}/var' -+runstatedir='${localstatedir}/run' - includedir='${prefix}/include' - oldincludedir='/usr/include' - docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -@@ -1489,6 +1492,15 @@ do - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - -+ -runstatedir | --runstatedir | --runstatedi | --runstated \ -+ | --runstate | --runstat | --runsta | --runst | --runs \ -+ | --run | --ru | --r) -+ ac_prev=runstatedir ;; -+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ -+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ -+ | --run=* | --ru=* | --r=*) -+ runstatedir=$ac_optarg ;; -+ - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ -@@ -1626,7 +1638,7 @@ fi - for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ -- libdir localedir mandir -+ libdir localedir mandir runstatedir - do - eval ac_val=\$$ac_var - # Remove trailing slashes. -@@ -1779,6 +1791,7 @@ Fine tuning of the installation directories: - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] -+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] -@@ -1884,6 +1897,7 @@ Optional Packages: - Add a custom string to the version string if build - number isn't set.[username_builddateb00] - --with-build-number Set build number value for build [b00] -+ --with-company-name Set company name. - --with-copyright-year Set copyright year value for build [current year] - --with-boot-jdk path to Boot JDK (used to bootstrap build) [probed] - --with-boot-jdk-jvmargs specify JVM arguments to be passed to all -@@ -4336,7 +4350,7 @@ VS_SDK_PLATFORM_NAME_2017= - #CUSTOM_AUTOCONF_INCLUDE - - # Do not change or remove the following line, it is needed for consistency checks: --DATE_WHEN_GENERATED=1523388104 -+DATE_WHEN_GENERATED=1536947420 - - ############################################################################### - # -@@ -19843,6 +19857,21 @@ fi - - - -+ # The company name, if any -+ -+# Check whether --with-company-name was given. -+if test "${with_company_name+set}" = set; then : -+ withval=$with_company_name; -+fi -+ -+ if test "x$with_company_name" = xyes; then -+ as_fn_error $? "--with-company-name must have a value" "$LINENO" 5 -+ elif ! [[ $with_company_name =~ ^[[:print:]]*$ ]] ; then -+ as_fn_error $? "--with-company-name contains non-printing characters: $with_company_name" "$LINENO" 5 -+ elif test "x$with_company_name" != x; then -+ COMPANY_NAME="$with_company_name" -+ fi -+ - - - # Check whether --with-copyright-year was given. diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 -index 6829d7af30..35e04f3342 100644 +index 18ba585209..ae9d5308f4 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 -@@ -509,10 +509,21 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_VERSION_NUMBERS], - AC_SUBST(PRODUCT_NAME) - AC_SUBST(PRODUCT_SUFFIX) - AC_SUBST(JDK_RC_PLATFORM_NAME) -- AC_SUBST(COMPANY_NAME) +@@ -539,6 +539,17 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_VERSION_NUMBERS], AC_SUBST(MACOSX_BUNDLE_NAME_BASE) AC_SUBST(MACOSX_BUNDLE_ID_BASE) @@ -150,16 +27,12 @@ index 6829d7af30..35e04f3342 100644 + elif test "x$with_company_name" != x; then + COMPANY_NAME="$with_company_name" + fi -+ AC_SUBST(COMPANY_NAME) + - AC_ARG_WITH(copyright-year, [AS_HELP_STRING([--with-copyright-year], - [Set copyright year value for build @<:@current year@:>@])]) - if test "x$with_copyright_year" = xyes; then -diff --git a/configure b/configure -old mode 100644 -new mode 100755 + # The vendor name, if any + AC_ARG_WITH(vendor-name, [AS_HELP_STRING([--with-vendor-name], + [Set vendor name. Among others, used to set the 'java.vendor' diff --git a/jdk/make/gensrc/GensrcMisc.gmk b/jdk/make/gensrc/GensrcMisc.gmk -index 9db5c9d6f7..0903ed642d 100644 +index 0e3dee5ca3..c137f371c7 100644 --- a/jdk/make/gensrc/GensrcMisc.gmk +++ b/jdk/make/gensrc/GensrcMisc.gmk @@ -30,6 +30,11 @@ include ProfileNames.gmk @@ -174,14 +47,14 @@ index 9db5c9d6f7..0903ed642d 100644 $(JDK_OUTPUTDIR)/gensrc/sun/misc/Version.java \ $(PROFILE_VERSION_JAVA_TARGETS): \ $(JDK_TOPDIR)/src/share/classes/sun/misc/Version.java.template -@@ -41,6 +46,7 @@ $(PROFILE_VERSION_JAVA_TARGETS): \ +@@ -40,6 +45,7 @@ $(PROFILE_VERSION_JAVA_TARGETS): \ + -e 's/@@java_version@@/$(RELEASE)/g' \ -e 's/@@java_runtime_version@@/$(FULL_VERSION)/g' \ -e 's/@@java_runtime_name@@/$(RUNTIME_NAME)/g' \ - -e 's/@@java_profile_name@@/$(call profile_version_name, $@)/g' \ + -e 's/@@company_name@@/$(company_name)/g' \ + -e 's/@@java_profile_name@@/$(call profile_version_name, $@)/g' \ $< > $@.tmp $(MV) $@.tmp $@ - diff --git a/jdk/src/share/classes/sun/misc/Version.java.template b/jdk/src/share/classes/sun/misc/Version.java.template index 32e2586e79..b1642d3f0a 100644 --- a/jdk/src/share/classes/sun/misc/Version.java.template @@ -214,3 +87,5 @@ index 32e2586e79..b1642d3f0a 100644 java_vm_info + ")"); } +-- +2.7.4 diff --git a/patches/jdk8u/ppc64le_1.patch b/patches/jdk8u/ppc64le_1.patch deleted file mode 100644 index dddeaa7a..00000000 --- a/patches/jdk8u/ppc64le_1.patch +++ /dev/null @@ -1,221 +0,0 @@ -From dd9fabc322bfd75ed2bec17c6d10e50ff402b6a4 Mon Sep 17 00:00:00 2001 -From: Martijn Verburg -Date: Mon, 17 Sep 2018 15:12:55 +0100 -Subject: [PATCH] Apply backported patch from - https://bugs.openjdk.java.net/browse/JDK-8073139 - -Signed-off-by: Martijn Verburg ---- - common/autoconf/generated-configure.sh | 7 +++++-- - common/autoconf/platform.m4 | 2 +- - hotspot/agent/src/os/linux/libproc.h | 2 +- - hotspot/make/defs.make | 12 +++++++++--- - hotspot/src/os/linux/vm/os_linux.cpp | 2 +- - hotspot/src/share/tools/hsdis/Makefile | 1 + - hotspot/src/share/tools/hsdis/hsdis-demo.c | 2 +- - hotspot/src/share/tools/hsdis/hsdis.c | 2 +- - hotspot/src/share/vm/runtime/vm_version.cpp | 9 +++++++-- - jdk/make/lib/SoundLibraries.gmk | 5 +++++ - jdk/test/tools/launcher/Settings.java | 2 +- - 11 files changed, 33 insertions(+), 13 deletions(-) - -diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh -index caf4963a93..49b788d10e 100644 ---- a/common/autoconf/generated-configure.sh -+++ b/common/autoconf/generated-configure.sh -@@ -13625,7 +13625,7 @@ test -n "$target_alias" && - VAR_CPU_ENDIAN=big - ;; - powerpc64le) -- VAR_CPU=ppc64 -+ VAR_CPU=ppc64le - VAR_CPU_ARCH=ppc - VAR_CPU_BITS=64 - VAR_CPU_ENDIAN=little -@@ -13763,7 +13763,7 @@ $as_echo "$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&6; } - VAR_CPU_ENDIAN=big - ;; - powerpc64le) -- VAR_CPU=ppc64 -+ VAR_CPU=ppc64le - VAR_CPU_ARCH=ppc - VAR_CPU_BITS=64 - VAR_CPU_ENDIAN=little -@@ -14586,6 +14586,9 @@ $as_echo "$with_jvm_variants" >&6; } - if test "x$VAR_CPU" = xppc64 ; then - INCLUDE_SA=false - fi -+ if test "x$VAR_CPU" = xppc64le ; then -+ INCLUDE_SA=false -+ fi - if test "x$OPENJDK_TARGET_CPU" = xaarch64; then - INCLUDE_SA=false - fi -diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4 -index bf109d5076..945579d606 100644 ---- a/common/autoconf/platform.m4 -+++ b/common/autoconf/platform.m4 -@@ -67,7 +67,7 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU], - VAR_CPU_ENDIAN=big - ;; - powerpc64le) -- VAR_CPU=ppc64 -+ VAR_CPU=ppc64le - VAR_CPU_ARCH=ppc - VAR_CPU_BITS=64 - VAR_CPU_ENDIAN=little -diff --git a/hotspot/agent/src/os/linux/libproc.h b/hotspot/agent/src/os/linux/libproc.h -index 03426c96ff..5d4ac3d2da 100644 ---- a/hotspot/agent/src/os/linux/libproc.h -+++ b/hotspot/agent/src/os/linux/libproc.h -@@ -68,7 +68,7 @@ combination of ptrace and /proc calls. - *************************************************************************************/ - - --#if defined(sparc) || defined(sparcv9) || defined(ppc64) -+#if defined(sparc) || defined(sparcv9) || defined(ppc64) || defined(ppc64le) - #include - #define user_regs_struct pt_regs - #endif -diff --git a/hotspot/make/defs.make b/hotspot/make/defs.make -index b5a41239cc..e553575dd6 100644 ---- a/hotspot/make/defs.make -+++ b/hotspot/make/defs.make -@@ -285,7 +285,7 @@ ifneq ($(OSNAME),windows) - - # Use uname output for SRCARCH, but deal with platform differences. If ARCH - # is not explicitly listed below, it is treated as x86. -- SRCARCH ?= $(ARCH/$(filter sparc sparc64 ia64 amd64 x86_64 ppc ppc64 zero,$(ARCH))) -+ SRCARCH ?= $(ARCH/$(filter sparc sparc64 ia64 amd64 x86_64 ppc ppc64 ppc64le zero,$(ARCH))) - ARCH/ = x86 - ARCH/sparc = sparc - ARCH/sparc64= sparc -@@ -293,6 +293,7 @@ ifneq ($(OSNAME),windows) - ARCH/amd64 = x86 - ARCH/x86_64 = x86 - ARCH/ppc64 = ppc -+ ARCH/ppc64le= ppc - ARCH/ppc = ppc - ARCH/zero = zero - -@@ -316,8 +317,13 @@ ifneq ($(OSNAME),windows) - endif - endif - -- # LIBARCH is 1:1 mapping from BUILDARCH -- LIBARCH ?= $(LIBARCH/$(BUILDARCH)) -+ # LIBARCH is 1:1 mapping from BUILDARCH, except for ARCH=ppc64le -+ ifeq ($(ARCH),ppc64le) -+ LIBARCH ?= ppc64le -+ else -+ LIBARCH ?= $(LIBARCH/$(BUILDARCH)) -+ endif -+ - LIBARCH/i486 = i386 - LIBARCH/amd64 = amd64 - LIBARCH/sparc = sparc -diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp -index d297445dc9..387ff03649 100644 ---- a/hotspot/src/os/linux/vm/os_linux.cpp -+++ b/hotspot/src/os/linux/vm/os_linux.cpp -@@ -1956,7 +1956,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) - {EM_SPARCV9, EM_SPARCV9, ELFCLASS64, ELFDATA2MSB, (char*)"Sparc v9 64"}, - {EM_PPC, EM_PPC, ELFCLASS32, ELFDATA2MSB, (char*)"Power PC 32"}, - #if defined(VM_LITTLE_ENDIAN) -- {EM_PPC64, EM_PPC64, ELFCLASS64, ELFDATA2LSB, (char*)"Power PC 64"}, -+ {EM_PPC64, EM_PPC64, ELFCLASS64, ELFDATA2LSB, (char*)"Power PC 64 LE"}, - #else - {EM_PPC64, EM_PPC64, ELFCLASS64, ELFDATA2MSB, (char*)"Power PC 64"}, - #endif -diff --git a/hotspot/src/share/tools/hsdis/Makefile b/hotspot/src/share/tools/hsdis/Makefile -index 35e96d8a31..0d1b608944 100644 ---- a/hotspot/src/share/tools/hsdis/Makefile -+++ b/hotspot/src/share/tools/hsdis/Makefile -@@ -97,6 +97,7 @@ ifdef LP64 - CFLAGS/sparcv9 += -m64 - CFLAGS/amd64 += -m64 - CFLAGS/ppc64 += -m64 -+CFLAGS/ppc64le += -m64 -DABI_ELFv2 - else - ARCH=$(ARCH1:amd64=i386) - CFLAGS/i386 += -m32 -diff --git a/hotspot/src/share/tools/hsdis/hsdis-demo.c b/hotspot/src/share/tools/hsdis/hsdis-demo.c -index 3037a4b7b9..bf4499ae67 100644 ---- a/hotspot/src/share/tools/hsdis/hsdis-demo.c -+++ b/hotspot/src/share/tools/hsdis/hsdis-demo.c -@@ -142,7 +142,7 @@ static const char* load_decode_instructions() { - - - static const char* lookup(void* addr) { --#if defined(__ia64) || defined(__powerpc__) -+#if defined(__ia64) || (defined(__powerpc__) && !defined(ABI_ELFv2)) - /* On IA64 and PPC function pointers are pointers to function descriptors */ - #define CHECK_NAME(fn) \ - if (addr == *((void**) &fn)) return #fn; -diff --git a/hotspot/src/share/tools/hsdis/hsdis.c b/hotspot/src/share/tools/hsdis/hsdis.c -index 430de855b8..7bef1040fb 100644 ---- a/hotspot/src/share/tools/hsdis/hsdis.c -+++ b/hotspot/src/share/tools/hsdis/hsdis.c -@@ -488,7 +488,7 @@ static const char* native_arch_name() { - #ifdef LIBARCH_sparcv9 - res = "sparc:v9b"; - #endif --#ifdef LIBARCH_ppc64 -+#if defined(LIBARCH_ppc64) || defined(LIBARCH_ppc64le) - res = "powerpc:common64"; - #endif - if (res == NULL) -diff --git a/hotspot/src/share/vm/runtime/vm_version.cpp b/hotspot/src/share/vm/runtime/vm_version.cpp -index 445f1b8465..c41d104d21 100644 ---- a/hotspot/src/share/vm/runtime/vm_version.cpp -+++ b/hotspot/src/share/vm/runtime/vm_version.cpp -@@ -184,13 +184,18 @@ const char* Abstract_VM_Version::jre_release_version() { - #ifndef CPU - #ifdef ZERO - #define CPU ZERO_LIBARCH -+#elif defined(PPC64) -+#if defined(VM_LITTLE_ENDIAN) -+#define CPU "ppc64le" -+#else -+#define CPU "ppc64" -+#endif - #else - #define CPU IA32_ONLY("x86") \ - IA64_ONLY("ia64") \ - AMD64_ONLY("amd64") \ -- PPC64_ONLY("ppc64") \ - SPARC_ONLY("sparc") --#endif // ZERO -+#endif - #endif - - const char *Abstract_VM_Version::vm_platform_string() { -diff --git a/jdk/make/lib/SoundLibraries.gmk b/jdk/make/lib/SoundLibraries.gmk -index 14580959cc..f22c9825e4 100644 ---- a/jdk/make/lib/SoundLibraries.gmk -+++ b/jdk/make/lib/SoundLibraries.gmk -@@ -139,6 +139,11 @@ else - ifeq ($(OPENJDK_TARGET_CPU), ppc64) - LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC64 - endif -+ -+ ifeq ($(OPENJDK_TARGET_CPU), ppc64le) -+ LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC64LE -+ endif -+ - endif - - LIBJSOUND_CFLAGS += -DEXTRA_SOUND_JNI_LIBS='"$(EXTRA_SOUND_JNI_LIBS)"' -diff --git a/jdk/test/tools/launcher/Settings.java b/jdk/test/tools/launcher/Settings.java -index 16fd29b0b1..8d45c8288b 100644 ---- a/jdk/test/tools/launcher/Settings.java -+++ b/jdk/test/tools/launcher/Settings.java -@@ -74,7 +74,7 @@ static void containsAllOptions(TestResult tr) { - - static void runTestOptionDefault() throws IOException { - String stackSize = "256"; // in kb -- if (getArch().equals("ppc64")) { -+ if (getArch().equals("ppc64") || getArch().equals("ppc64le")) { - stackSize = "800"; - } - TestResult tr = null; diff --git a/patches/jdk8u/ppc64le_2.patch b/patches/jdk8u/ppc64le_2.patch deleted file mode 100644 index 3d879425..00000000 --- a/patches/jdk8u/ppc64le_2.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 8b40b63897b02866e74cb224097c7fafc86b468d Mon Sep 17 00:00:00 2001 -From: Martijn Verburg -Date: Mon, 17 Sep 2018 16:29:34 +0100 -Subject: [PATCH] add missing jvm.cfg file - ---- - jdk/src/solaris/bin/ppc64le/jvm.cfg | 33 +++++++++++++++++++++++++++++ - 1 file changed, 33 insertions(+) - create mode 100644 jdk/src/solaris/bin/ppc64le/jvm.cfg - -diff --git a/jdk/src/solaris/bin/ppc64le/jvm.cfg b/jdk/src/solaris/bin/ppc64le/jvm.cfg -new file mode 100644 -index 0000000000..2fc1214175 ---- /dev/null -+++ b/jdk/src/solaris/bin/ppc64le/jvm.cfg -@@ -0,0 +1,33 @@ -+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. -+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -+# -+# This code is free software; you can redistribute it and/or modify it -+# under the terms of the GNU General Public License version 2 only, as -+# published by the Free Software Foundation. Oracle designates this -+# particular file as subject to the "Classpath" exception as provided -+# by Oracle in the LICENSE file that accompanied this code. -+# -+# This code is distributed in the hope that it will be useful, but WITHOUT -+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -+# version 2 for more details (a copy is included in the LICENSE file that -+# accompanied this code). -+# -+# You should have received a copy of the GNU General Public License version -+# 2 along with this work; if not, write to the Free Software Foundation, -+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -+# -+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -+# or visit www.oracle.com if you need additional information or have any -+# questions. -+# -+# List of JVMs that can be used as an option to java, javac, etc. -+# Order is important -- first in this list is the default JVM. -+# NOTE that this both this file and its format are UNSUPPORTED and -+# WILL GO AWAY in a future release. -+# -+# You may also select a JVM in an arbitrary location with the -+# "-XXaltjvm=" option, but that too is unsupported -+# and may not be available in a future release. -+# -+-server KNOWN diff --git a/patches/riscv-port-jdk11u/actions-ignore-branches.patch b/patches/riscv-port-jdk11u/actions-ignore-branches.patch new file mode 100644 index 00000000..e69de29b diff --git a/skaraMirror.sh b/skaraMirror.sh index a53a975a..392c89b8 100755 --- a/skaraMirror.sh +++ b/skaraMirror.sh @@ -32,6 +32,48 @@ function checkArgs() { fi } +# For jdk8u-based repos, common/autoconf/generated-configure.sh is a build-generated file +# that frequently conflicts during merges/rebases/patches because it is regenerated from +# common/autoconf/*.m4 sources. This function checks if it is the ONLY conflict and if so, +# regenerates it via autogen.sh and stages the result. +# Must be called from within the repo working directory. +# Returns 0 if the conflict was resolved, 1 if there are other conflicts (caller must fail). +function resolveGeneratedConfigureConflict() { + local GENERATED_CONFIGURE="common/autoconf/generated-configure.sh" + local AUTOGEN="common/autoconf/autogen.sh" + + # Only applies to jdk8u-based repos that have the autogen script + if [[ "${VERSION}" != "8" ]]; then + return 1 + fi + + # Get list of conflicted files + local conflicts + conflicts=$(git diff --name-only --diff-filter=U) + + if [[ -z "$conflicts" ]]; then + return 1 + fi + + # Check if generated-configure.sh is the only conflict + if [[ "$conflicts" != "$GENERATED_CONFIGURE" ]]; then + echo "ERROR: Conflicts exist in files other than $GENERATED_CONFIGURE:" + echo "$conflicts" + return 1 + fi + + echo "Resolving $GENERATED_CONFIGURE conflict by regenerating via autogen.sh" + if [ ! -f "$AUTOGEN" ]; then + echo "ERROR: $AUTOGEN not found — cannot regenerate $GENERATED_CONFIGURE" + return 1 + fi + + bash "$AUTOGEN" || return 1 + git add "$GENERATED_CONFIGURE" || return 1 + echo "Successfully regenerated and staged $GENERATED_CONFIGURE" + return 0 +} + function cloneGitHubRepo() { cd "$WORKSPACE" || exit 1 # If we don't have a $GITHUB_REPO locally then clone it from adoptium/$GITHUB_REPO.git @@ -44,27 +86,46 @@ function addSkaralUpstream() { cd "$WORKSPACE/$GITHUB_REPO" || exit 1 git fetch --all - if ! git checkout -f "$BRANCH" ; then - if ! git rev-parse -q --verify "origin/$BRANCH" ; then - git checkout -b "$BRANCH" || exit 1 - else - git checkout -b "$BRANCH" origin/"$BRANCH" || exit 1 - fi - else - git reset --hard origin/"$BRANCH" || echo "Not resetting as no upstream exists" - fi + # Ensure the skara remote exists before we need it # shellcheck disable=SC2143 if [ -z "$(git remote -v | grep 'skara')" ] ; then echo "Initial setup of $SKARA_REPO" git remote add skara "$SKARA_REPO" fi + + # Fetch skara so skara/$BRANCH is available for branch creation below + git fetch skara + + if ! git checkout -f "$BRANCH" ; then + if ! git rev-parse -q --verify "origin/$BRANCH" ; then + # Branch does not exist locally or on origin — create it from skara/$BRANCH + # so it starts at the correct upstream commit, not the current HEAD + git checkout -b "$BRANCH" "skara/$BRANCH" || exit 1 + else + git checkout -b "$BRANCH" "origin/$BRANCH" || exit 1 + fi + else + # Only reset to origin/$BRANCH if it has been pushed there previously + if git rev-parse -q --verify "origin/$BRANCH" ; then + git reset --hard "origin/$BRANCH" || exit 1 + else + echo "No origin/$BRANCH exists yet, skipping reset" + fi + fi } function performMergeFromSkaraIntoGit() { git fetch skara --tags - git rebase "skara/$BRANCH" "$BRANCH" + if ! git rebase "skara/$BRANCH" "$BRANCH" ; then + if resolveGeneratedConfigureConflict ; then + git rebase --continue || exit 1 + else + git rebase --abort + exit 1 + fi + fi git push -u origin "$BRANCH" || exit 1 git push origin "$BRANCH" --tags || exit 1 @@ -85,10 +146,13 @@ function performMergeIntoReleaseFromMaster() { buildTags=$(git tag --merged origin/"$BRANCH" $TAG_SEARCH || exit 1) sortedBuildTags=$(echo "$buildTags" | eval "$jdk_sort_tags_cmd" || exit 1) + NEW_RELEASE_BRANCH_TAG="" if ! git checkout -f "$RELEASE_BRANCH" ; then if ! git rev-parse -q --verify "origin/$RELEASE_BRANCH" ; then currentBuildTag=$(echo "$buildTags" | eval "$jdk_sort_tags_cmd" | tail -1 || exit 1) git checkout -b "$RELEASE_BRANCH" $currentBuildTag || exit 1 + # Remember the tag this new branch was created from so we can _adopt tag it after patching + NEW_RELEASE_BRANCH_TAG="$currentBuildTag" else git checkout -b "$RELEASE_BRANCH" "origin/$RELEASE_BRANCH" || exit 1 fi @@ -96,22 +160,95 @@ function performMergeIntoReleaseFromMaster() { git reset --hard "origin/$RELEASE_BRANCH" || echo "Not resetting as no upstream exists" fi - # Apply our patches to release branch - echo "Checking if patches need to be applied for $GITHUB_REPO" + # Apply Adoptium patches to release branch, gated on README.JAVASE not existing + # (README.JAVASE is the Adoptium marker file — its absence means no patches have been applied yet) + if [ ! -f "$WORKSPACE/$GITHUB_REPO/README.JAVASE" ]; then + echo "Applying Adoptium patches for $GITHUB_REPO" + + # Step 1: Apply top-level patches, skipping any whose filename also exists in patches// + # (repo-specific patches in the sub-folder take precedence and will be applied in step 2) + for patchFile in "$PATCHES"*.patch; do + [ -f "$patchFile" ] || continue + patchName=$(basename "$patchFile") + if [ -f "$PATCHES$GITHUB_REPO/$patchName" ]; then + echo "Skipping top-level $patchName (overridden by patches/$GITHUB_REPO/$patchName)" + else + echo "Applying top-level patch: $patchName" + if [[ ! -s "$patchFile" ]]; then + echo "Skipping empty patch: $patchName" + continue + fi + if ! git am --ignore-whitespace -3 "$patchFile" ; then + if resolveGeneratedConfigureConflict ; then + git am --continue || exit 1 + else + git am --abort + exit 1 + fi + fi + fi + done + + # Step 2: Apply repo-specific patches from patches// if that folder exists + # Use --ignore-whitespace -3 for 3-way merge fallback, which handles context mismatches + # when patches were generated against an older version of upstream files + if [ -d "$PATCHES$GITHUB_REPO" ]; then + for patchFile in "$PATCHES$GITHUB_REPO"/*.patch; do + [ -f "$patchFile" ] || continue + patchName=$(basename "$patchFile") + echo "Applying repo-specific patch: $patchName" + if [[ ! -s "$patchFile" ]]; then + echo "Skipping empty patch: $patchName" + continue + fi + if ! git am --ignore-whitespace -3 "$patchFile" ; then + if resolveGeneratedConfigureConflict ; then + git am --continue || exit 1 + else + git am --abort + exit 1 + fi + fi + done + fi - # actions ignore branch patch is for > jdk11u - if [[ "$GITHUB_REPO" != "jdk8u" ]] && [[ "$GITHUB_REPO" != "aarch32-port-jdk8u" ]] && [[ "$GITHUB_REPO" != "jdk11u" ]]; then - # check to see if patch has already been applied - if ! grep -q "\\- dev" "$WORKSPACE/$GITHUB_REPO/.github/workflows/main.yml"; then - echo "Applying actions-ignore-branches.patch" - git am $PATCHES/actions-ignore-branches.patch + # For JDK 8 repos, regenerate generated-configure.sh after all patches have been applied. + # company_name.patch modifies jdk-options.m4 but does not include the generated file + # (unlike the alpine-jdk8u variant which bundles both). The JDK 8 configure wrapper + # runs the checked-in generated script, so without regeneration --with-company-name + # is unavailable at build time. autogen.sh is idempotent — if the patch already + # included the generated file (e.g. alpine-jdk8u/0002) this produces no diff. + if [[ "${VERSION}" == "8" ]]; then + local AUTOGEN="common/autoconf/autogen.sh" + local GENERATED="common/autoconf/generated-configure.sh" + if [ -f "$AUTOGEN" ]; then + echo "Regenerating $GENERATED after patch application" + bash "$AUTOGEN" || exit 1 + if ! git diff --quiet "$GENERATED" ; then + git add "$GENERATED" + git commit --no-edit -m "Regenerate generated-configure.sh after Adoptium patches" || exit 1 + echo "Committed regenerated $GENERATED" + else + echo "$GENERATED already up to date, no commit needed" + fi + else + echo "WARNING: $AUTOGEN not found — skipping $GENERATED regeneration" + fi fi - fi - # README.JAVASE patch needed for all repos - if [ ! -f "$WORKSPACE/$GITHUB_REPO/README.JAVASE" ]; then - echo "Applying README.JAVASE.patch" - git am $PATCHES/readme-javase.patch + # If this is a brand new release branch, tag the base build tag with _adopt now that + # patches have been applied — the merge loop below will find no new tags to process + if [[ -n "$NEW_RELEASE_BRANCH_TAG" ]]; then + local adoptTag="${NEW_RELEASE_BRANCH_TAG}_adopt" + if [ "$(git tag -l "$adoptTag")" == "" ]; then + echo "Tagging new $RELEASE_BRANCH base tag ${adoptTag}" + git tag -a "$adoptTag" -m "Merged ${NEW_RELEASE_BRANCH_TAG} into $RELEASE_BRANCH" || exit 1 + else + echo "Adopt tag ${adoptTag} already exists, skipping" + fi + fi + else + echo "README.JAVASE already exists — patches already applied, skipping" fi # Find the latest release tag that is not in releaseTagExcludeList @@ -158,7 +295,14 @@ function performMergeIntoReleaseFromMaster() { fi if [[ "$mergeTag" == true ]]; then echo "Merging build tag $tag into $RELEASE_BRANCH branch" - git merge -m"Merging $tag into $RELEASE_BRANCH" $tag || exit 1 + if ! git merge -m"Merging $tag into $RELEASE_BRANCH" $tag ; then + if resolveGeneratedConfigureConflict ; then + git commit --no-edit || exit 1 + else + git merge --abort + exit 1 + fi + fi git tag -a "${tag}_adopt" -m "Merged $tag into $RELEASE_BRANCH" || exit 1 newAdoptTags="${newAdoptTags} ${tag}_adopt" fi @@ -232,12 +376,20 @@ function performMergeIntoDevFromMaster() { if ! git checkout -f "$DEV_BRANCH" ; then if ! git rev-parse -q --verify "origin/$DEV_BRANCH" ; then - git checkout -b "$DEV_BRANCH" || exit 1 + # Branch does not exist locally or on origin — create it from $BRANCH (upstream default, + # already at latest HEAD from performMergeFromSkaraIntoGit), not from current HEAD + # which will be RELEASE_BRANCH after performMergeIntoReleaseFromMaster() + git checkout -b "$DEV_BRANCH" "$BRANCH" || exit 1 else git checkout -b "$DEV_BRANCH" "origin/$DEV_BRANCH" || exit 1 fi else - git reset --hard "origin/$DEV_BRANCH" || echo "Not resetting as no upstream exists" + # Only reset to origin/$DEV_BRANCH if it has been pushed there previously + if git rev-parse -q --verify "origin/$DEV_BRANCH" ; then + git reset --hard "origin/$DEV_BRANCH" || exit 1 + else + echo "No origin/$DEV_BRANCH exists yet, skipping reset" + fi fi devTags=$(git tag --merged "$DEV_BRANCH" $TAG_SEARCH || exit 1) @@ -246,10 +398,24 @@ function performMergeIntoDevFromMaster() { # Merge master "HEAD" echo "Merging origin/$BRANCH HEAD into $DEV_BRANCH branch" - git merge -m"Merging origin/$BRANCH HEAD into $DEV_BRANCH" origin/"$BRANCH" || exit 1 + if ! git merge -m"Merging origin/$BRANCH HEAD into $DEV_BRANCH" origin/"$BRANCH" ; then + if resolveGeneratedConfigureConflict ; then + git commit --no-edit || exit 1 + else + git merge --abort + exit 1 + fi + fi # Merge latest patches from "release" branch - git merge -m"Merging latest patches from $RELEASE_BRANCH branch" "origin/$RELEASE_BRANCH" || exit 1 + if ! git merge -m"Merging latest patches from $RELEASE_BRANCH branch" "origin/$RELEASE_BRANCH" ; then + if resolveGeneratedConfigureConflict ; then + git commit --no-edit || exit 1 + else + git merge --abort + exit 1 + fi + fi if git rev-parse -q --verify "origin/$DEV_BRANCH" ; then git --no-pager log --oneline "origin/$DEV_BRANCH..$DEV_BRANCH" @@ -264,20 +430,33 @@ function performMergeIntoDevFromMaster() { checkArgs $# -SKARA_REPO="https://github.com/openjdk/$1" GITHUB_REPO="$1" -REPO=${2:-"git@github.com:adoptium/$GITHUB_REPO"} -BRANCH=${BRANCH:=master} -# Does this OpenJDK repo support version branching? -VERSION_BRANCHING=false +# alpine-jdk8u mirrors from the upstream jdk8u Skara repo +if [[ "${GITHUB_REPO}" == "alpine-jdk8u" ]]; then + SKARA_REPO="https://github.com/openjdk/jdk8u" +else + SKARA_REPO="https://github.com/openjdk/${GITHUB_REPO}" +fi + +# aarch32-port-jdk8u mirrors to the Adoptium repo named aarch32-jdk8u (without the "port-" prefix) +if [[ "${GITHUB_REPO}" == "aarch32-port-jdk8u" ]]; then + REPO=${2:-"git@github.com:adoptium/aarch32-jdk8u"} +else + REPO=${2:-"git@github.com:adoptium/$GITHUB_REPO"} +fi -# jdk(head) is only repository currently supporting version branches -if [[ "${GITHUB_REPO}" == "jdk" ]]; then - VERSION_BRANCHING=true +# Determine the default branch of the upstream Skara repo via git ls-remote (no API token needed) +SKARA_DEFAULT_BRANCH=$(git ls-remote --symref "${SKARA_REPO}" HEAD | grep '^ref:' | sed 's|ref: refs/heads/||;s/[[:space:]].*//' | tr -d '[:space:]') +if [[ -z "${SKARA_DEFAULT_BRANCH}" ]]; then + echo "ERROR: Could not determine default branch for ${SKARA_REPO} - git ls-remote --symref returned unexpected output" + exit 1 fi +echo "Upstream default branch: ${SKARA_DEFAULT_BRANCH}" + +BRANCH=${BRANCH:=${SKARA_DEFAULT_BRANCH}} -if [[ "${VERSION_BRANCHING}" == false ]] || [[ "${BRANCH}" == "master" ]]; then +if [[ "${BRANCH}" == "${SKARA_DEFAULT_BRANCH}" ]]; then RELEASE_BRANCH="release" DEV_BRANCH="dev" else @@ -307,7 +486,11 @@ fi jdk11plus_tag_sort1="sort -t+ -k2,2n" # Second, (stable) sort on (V), (W), (X), (P): P(Patch) is optional and defaulted to "0" jdk11plus_tag_sort2="sort -t. -k2,2n -k3,3n -k4,4n -k5,5n" -# Ignore "..+0" branch fork point tags +# Ignore "..+0" branch fork point tags — these mark where the next version branched off master +# and are not real builds. Build tags for the next version (e.g. jdk-21.0.15+1) only appear on +# that new branch, never on master, so +0 is always the last visible tag for that version on +# master. Including it would advance currentReleaseTag past any not-yet-tagged current-version +# builds (e.g. jdk-21.0.14 GA), permanently locking them out of the merge loop. jdk11plus_sort_tags_cmd="grep -v _adopt | grep -v '\+0$' | sed 's/jdk-/jdk./g' | sed 's/+/.0.0+/g' | $jdk11plus_tag_sort1 | nl -n rz | $jdk11plus_tag_sort2 | sed 's/\.0\.0+/+/g' | cut -f2- | sed 's/jdk./jdk-/g'" # JDK8 tag sorting: @@ -317,8 +500,9 @@ jdk11plus_sort_tags_cmd="grep -v _adopt | grep -v '\+0$' | sed 's/jdk-/jdk./g' | jdk8_tag_sort1="sort -tb -k2,2n" # Second, (stable) sort on (V), (W) jdk8_tag_sort2="sort -tu -k2,2n" -# Ignore "..-b00" branch fork point tags -jdk8_sort_tags_cmd="grep -v _adopt | grep -v '\-b00$' | $jdk8_tag_sort1 | nl -n rz | $jdk8_tag_sort2 | cut -f2-" +# Ignore "..-b00" branch fork point tags (same reasoning as jdk11+ above). +# Note: no "$" anchor — aarch32 tags embed -b00 mid-string, e.g. jdk8u504-b00-aarch32-20260731. +jdk8_sort_tags_cmd="grep -v _adopt | grep -v '\-b00' | $jdk8_tag_sort1 | nl -n rz | $jdk8_tag_sort2 | cut -f2-" if [[ "${VERSION}" == "8" ]]; then @@ -327,6 +511,13 @@ else jdk_sort_tags_cmd="${jdk11plus_sort_tags_cmd}" fi +# For aarch32-port-jdk8u, the upstream Skara repo also contains non-aarch32 tags (inherited from +# the parent jdk8u repo). Prepend a filter so only tags containing "aarch32" are considered — +# this prevents non-aarch32 tags from being picked as the branch-point or merged into release/dev. +if [[ "${GITHUB_REPO}" == "aarch32-port-jdk8u" ]]; then + jdk_sort_tags_cmd="grep 'aarch32' | ${jdk_sort_tags_cmd}" +fi + cloneGitHubRepo addSkaralUpstream performMergeFromSkaraIntoGit