From 975bc3e9714629c3e535bf35c28d2d3486dcd6bf Mon Sep 17 00:00:00 2001 From: Simon Frankenberger Date: Wed, 6 Dec 2023 21:23:42 +0100 Subject: [PATCH] community/openjdk17-ppc64le-bootstrap: new aport This temporary aport is used to bootstrap OpenJDK17 on ppc64le again --- .../openjdk17-ppc64le-bootstrap/APKBUILD | 371 ++++++++++++++++++ .../openjdk17-ppc64le-bootstrap/ppc64le.patch | 278 +++++++++++++ 2 files changed, 649 insertions(+) create mode 100644 community/openjdk17-ppc64le-bootstrap/APKBUILD create mode 100644 community/openjdk17-ppc64le-bootstrap/ppc64le.patch diff --git a/community/openjdk17-ppc64le-bootstrap/APKBUILD b/community/openjdk17-ppc64le-bootstrap/APKBUILD new file mode 100644 index 00000000000..862426adbd2 --- /dev/null +++ b/community/openjdk17-ppc64le-bootstrap/APKBUILD @@ -0,0 +1,371 @@ +# Contributor: Simon Frankenberger +# Maintainer: Simon Frankenberger +pkgname=openjdk17-ppc64le-bootstrap +pkgver=17.0.9_p8 +_pkgver=${pkgver%_p*}-ga +pkgrel=0 +pkgdesc="Oracle OpenJDK 17" +provider_priority=17 +url="https://github.com/openjdk/jdk17u" +# oracle dropped support for 32 bit +# java not available for risvc64 +arch="ppc64le" +license="GPL-2.0-with-classpath-exception" +makedepends=" + openjdk17 + autoconf + bash + gawk + grep + make + zip + alsa-lib-dev + cups-dev + elfutils-dev + fontconfig-dev + freetype-dev + giflib-dev + lcms2-dev + libffi-dev + libjpeg-turbo-dev + libx11-dev + libxext-dev + libxrandr-dev + libxrender-dev + libxt-dev + libxtst-dev + linux-headers + zlib-dev + " +depends="$pkgname-jdk $pkgname-demos $pkgname-doc" # for the virtual openjdk16 package +subpackages="$pkgname-jmods:_jmods:noarch + $pkgname-demos:_demos:noarch + $pkgname-doc:_doc:noarch + $pkgname-jre:_jre + $pkgname-src:_src:noarch + $pkgname-static-libs:_static_libs + $pkgname-jre-headless:_jre_headless + $pkgname-jdk:_jdk + " +source="jdk-$_pkgver.tar.gz::https://github.com/openjdk/jdk17u/archive/jdk-$_pkgver.tar.gz + gtest-1.8.1.tar.gz::https://github.com/google/googletest/archive/release-1.8.1.tar.gz + ppc64le.patch +" +builddir="$srcdir/jdk17u-jdk-${_pkgver/+/-}" + +provides="openjdk17-bootstrap=$pkgver-r$pkgrel" + +_java_home="/usr/lib/jvm/java-17-openjdk" + +ldpath="$_java_home/lib:$_java_home/lib/server" +sonameprefix="$pkgname:" + +# enable running the JTReg tests in check? +# see comment in that function for explanation +_run_jtreg=${_run_jtreg:-0} +if [ $_run_jtreg -ne 0 ]; then + makedepends="$makedepends java-jtreg" + checkdepends="$checkdepends font-freefont xvfb-run" +fi + +# secfixes: +# 17.0.9_p8-r0: +# - CVE-2023-30589 +# - CVE-2023-22081 +# - CVE-2023-22025 +# 17.0.8_p7-r0: +# - CVE-2023-22041 +# - CVE-2023-25193 +# - CVE-2023-22044 +# - CVE-2023-22045 +# - CVE-2023-22049 +# - CVE-2023-22036 +# - CVE-2023-22006 +# 17.0.7_p7-r0: +# - CVE-2023-21930 +# - CVE-2023-21967 +# - CVE-2023-21954 +# - CVE-2023-21939 +# - CVE-2023-21938 +# - CVE-2023-21968 +# - CVE-2023-21937 +# 17.0.6_p10-r0: +# - CVE-2023-21835 +# - CVE-2023-21843 +# 17.0.5_p8-r0: +# - CVE-2022-21628 +# - CVE-2022-21618 +# - CVE-2022-39399 +# - CVE-2022-21624 +# - CVE-2022-21619 +# 17.0.4_p8-r0: +# - CVE-2022-21540 +# - CVE-2022-21541 +# - CVE-2022-21549 +# - CVE-2022-25647 +# - CVE-2022-34169 +# 17.0.3_p7-r0: +# - CVE-2022-21426 +# - CVE-2022-21449 +# - CVE-2022-21434 +# - CVE-2022-21443 +# - CVE-2022-21476 +# - CVE-2022-21496 +# 17.0.2_p8-r0: +# - CVE-2022-21291 +# - CVE-2022-21305 +# - CVE-2022-21277 +# - CVE-2022-21360 +# - CVE-2022-21365 +# - CVE-2022-21366 +# - CVE-2022-21282 +# - CVE-2022-21296 +# - CVE-2022-21299 +# - CVE-2022-21283 +# - CVE-2022-21293 +# - CVE-2022-21294 +# - CVE-2022-21340 +# - CVE-2022-21341 +# - CVE-2022-21248 +# 17.0.1_p12-r0: +# - CVE-2021-35567 +# - CVE-2021-35586 +# - CVE-2021-35564 +# - CVE-2021-35556 +# - CVE-2021-35559 +# - CVE-2021-35561 +# - CVE-2021-35578 +# - CVE-2021-35603 + +prepare() { + default_prepare + # update autoconf files to detect alpine + update_config_sub +} + +build() { + if [ $_run_jtreg -ne 0 ]; then + _with_jtreg="--with-jtreg=/usr/share/java/jtreg" + else + _with_jtreg="--with-jtreg=no" + fi + + if [ -n "$USE_CCACHE" ]; then + # workaround ccache being disallowed + export PATH="/usr/bin:/bin:/sbin:/usr/sbin" + local ccache="--enable-ccache" + fi + + export CFLAGS="$CFLAGS -Wno-format -Wno-error=format-security" + export CXXFLAGS="$CXXFLAGS -Wno-format -Wno-error=format-security" + export CPPFLAGS="$CPPFLAGS -Wno-format -Wno-error=format-security" + + # we want to build hotspot with better optimisations; it's set to this + # (prepended) anyway, and it's huge + export CFLAGS="$CFLAGS -O3" + export CXXFLAGS="$CXXFLAGS -O3" + + # CFLAGS, CXXFLAGS and LDFLAGS are ignored as shown by a warning + # in the output of ./configure unless used like such: + # --with-extra-cflags="$CFLAGS" + # --with-extra-cxxflags="$CXXFLAGS" + # --with-extra-ldflags="$LDFLAGS" + # See also paragraph "Configure Control Variables" from "common/doc/building.md" + # shellcheck disable=2097 disable=2098 + CFLAGS='' CXXFLAGS='' LDFLAGS='' \ + bash ./configure \ + --build=$CBUILD \ + --host=$CHOST \ + --target=$CTARGET \ + --prefix="$_java_home" \ + --sysconfdir=/etc \ + --mandir=/usr/share/man \ + --infodir=/usr/share/info \ + --localstatedir=/var \ + --with-extra-cflags="$CFLAGS -D_LARGEFILE64_SOURCE" \ + --with-extra-cxxflags="$CXXFLAGS -D_LARGEFILE64_SOURCE" \ + --with-extra-ldflags="$LDFLAGS" \ + --with-zlib=system \ + --with-libjpeg=system \ + --with-giflib=system \ + --with-libpng=system \ + --with-lcms=system \ + --with-jobs=${JOBS:-4} \ + --with-test-jobs=${JOBS:-4} \ + --with-native-debug-symbols=none \ + --with-gtest=../googletest-release-1.8.1 \ + $ccache \ + $_with_jtreg \ + --disable-warnings-as-errors \ + --disable-precompiled-headers \ + --enable-dtrace=no \ + --with-jvm-variants=server \ + --with-debug-level=release \ + --with-version-pre= \ + --with-version-opt="alpine-r$pkgrel" \ + --with-version-build="${pkgver##*p}" \ + --with-vendor-name="Alpine" \ + --with-vendor-url="https://alpinelinux.org/" \ + --with-vendor-bug-url="https://gitlab.alpinelinux.org/alpine/aports/issues" \ + --with-vendor-vm-bug-url="https://gitlab.alpinelinux.org/alpine/aports/issues" \ + --with-boot-jdk-jvmargs="-Djdk.lang.Process.launchMechanism=fork" + # in rare cases the build hangs + MAKEFLAGS='' timeout 3600 make jdk-image + MAKEFLAGS='' make static-libs-image +} + +check() { + # run the gtest unittest suites + # they don't take long, DO NOT DISABLE THEM! + MAKEFLAGS='' make test-hotspot-gtest + + # The jtreg tests take very, very long to finish and show some failures (9 - 12 on my machine, varying between runs) + # I think these are not critical and can be safely ignored. + # As the tests take too long, they are disabled by default. + # When updating this aport please let them run at least once on your machine to see if the failure count changes. + if [ $_run_jtreg -ne 0 ]; then + _logfile=$( mktemp -p "$builddir" ) + MAKEFLAGS='' xvfb-run make \ + run-test-tier1 \ + run-test-tier2 \ + run-test-tier3 \ + | tee "$_logfile" + msg "---------------------------------------" + msg "The build log can be found at $_logfile" + # abort the build so you may take a look at the logfile + false + return 1 + fi +} + +package() { + local libstaticdir="lib/static/linux-${CARCH/x86_64/amd64}/musl" + + mkdir -p "$pkgdir/$_java_home/$libstaticdir" + + cd build/linux-*-server-release/images/ + cp -r jdk/* "$pkgdir/$_java_home" + cp -r static-libs/lib/* "$pkgdir/$_java_home/$libstaticdir" +} + +_jmods() { + pkgdesc="Oracle OpenJDK 17 (jmods)" + depends="" + _fromroot="$pkgdir/$_java_home" + _toroot="$subpkgdir/$_java_home" + + mkdir -p "$_toroot" + mv "$_fromroot/jmods" "$_toroot" +} + +_demos() { + pkgdesc="Oracle OpenJDK 17 (demos)" + depends="" + _fromroot="$pkgdir/$_java_home" + _toroot="$subpkgdir/$_java_home" + + mkdir -p "$_toroot" + mv "$_fromroot/demo" "$_toroot" +} + +_doc() { + pkgdesc="Oracle OpenJDK 17 (Documentation)" + depends="" + _fromroot="$pkgdir/$_java_home" + _toroot="$subpkgdir/$_java_home" + + mkdir -p "$_toroot" + mv "$_fromroot/man" "$_toroot" +} + +_jre() { + pkgdesc="Oracle OpenJDK 17 (JRE)" + depends="$pkgname-jre-headless" + provides=java-jre + _fromroot="$pkgdir/$_java_home" + _toroot="$subpkgdir/$_java_home" + + mkdir -p "$_toroot/lib" + mv "$_fromroot/lib/libawt_xawt.so" \ + "$_fromroot/lib/libfontmanager.so" \ + "$_fromroot/lib/libjavajpeg.so" \ + "$_fromroot/lib/libjawt.so" \ + "$_fromroot/lib/libjsound.so" \ + "$_fromroot/lib/liblcms.so" \ + "$_fromroot/lib/libsplashscreen.so" \ + "$_toroot/lib" +} + +_src() { + pkgdesc="Oracle OpenJDK 17 (sources)" + depends="$pkgname-jre-headless" + mkdir -p "$subpkgdir/$_java_home"/lib + mv "$pkgdir"/$_java_home/lib/src.zip \ + "$subpkgdir"/$_java_home/lib/ +} + +_static_libs() { + pkgdesc="Oracle OpenJDK 17 libraries for static linking" + provides="java-jdk-static-libs" + depends="$pkgname=$pkgver-r$pkgrel" + + amove $_java_home/lib/static +} + +_jre_headless() { + pkgdesc="Oracle OpenJDK 17 (JRE headless)" + depends="java-common java-cacerts" + provides=java-jre-headless + _fromroot="$pkgdir/$_java_home" + _toroot="$subpkgdir/$_java_home" + + mkdir -p "$_toroot" + mv "$_fromroot/lib" "$_toroot" + + # ct.sym should stay in -jdk + mkdir "$_fromroot/lib" + mv "$_toroot/lib/ct.sym" "$_fromroot/lib" + + mkdir -p "$_toroot/bin" + for i in java \ + jfr \ + jrunscript \ + keytool \ + rmiregistry; do + mv "$_fromroot/bin/$i" "$_toroot/bin/$i" + done + + mv "$_fromroot/legal" "$_toroot" + mv "$_fromroot/conf" "$_toroot" + mv "$_fromroot/release" "$_toroot" + cp "$builddir/ASSEMBLY_EXCEPTION" "$_toroot" + cp "$builddir/LICENSE" "$_toroot" + cp "$builddir/README.md" "$_toroot" + + # symlink to shared cacerts store + rm "$_toroot/lib/security/cacerts" + ln -sf /etc/ssl/certs/java/cacerts \ + "$_toroot/lib/security/cacerts" + + # symlink for java-common to work (expects jre in $_java_home/jre) + ln -sf . "$_toroot/jre" +} + +_jdk() { + pkgdesc="Oracle OpenJDK 17 (JDK)" + depends="$pkgname-jre $pkgname-jmods" + provides=java-jdk + _fromroot="$pkgdir/$_java_home" + _toroot="$subpkgdir/$_java_home" + + mkdir -p "$_toroot" + mv "$_fromroot/bin" "$_toroot" + mv "$_fromroot/lib" "$_toroot" + mv "$_fromroot/include" "$_toroot" +} + +sha512sums=" +88a454d38e03784a32c7b2ffbb1fcf1df07d6ebb2658ee73a80dd5c703b9ae09794ef5633caf0e8b07f97a94cb841ce41892cfc19eedb3b9fa57dc51c8d08784 jdk-17.0.9-ga.tar.gz +e6283c667558e1fd6e49fa96e52af0e415a3c8037afe1d28b7ff1ec4c2ef8f49beb70a9327b7fc77eb4052a58c4ccad8b5260ec90e4bceeac7a46ff59c4369d7 gtest-1.8.1.tar.gz +007e643039af096e77e491ccba821596c7e96b80d9821a7fbe4a78ca3f013c5e771956461d82505c26b0ca3ab06699877f398833db459e2442c0c51f71fee361 ppc64le.patch +" diff --git a/community/openjdk17-ppc64le-bootstrap/ppc64le.patch b/community/openjdk17-ppc64le-bootstrap/ppc64le.patch new file mode 100644 index 00000000000..eeef53917a4 --- /dev/null +++ b/community/openjdk17-ppc64le-bootstrap/ppc64le.patch @@ -0,0 +1,278 @@ +Subject: Fix compilation with different ucontext_t on musl +Upstream: No +Author: Simon Frankenberger + +The machine state registers have to be accessed differently when +running on musl libc. This patch fix this by replacing +"uc_mcontext.regs->grp" with "uc_mcontext.gp_regs" +and accessing the named fields (like "->nip") by the array index constants. + +--- old/make/common/TestFilesCompilation.gmk ++++ new/make/common/TestFilesCompilation.gmk +@@ -99,7 +99,7 @@ + CFLAGS := $$($1_BASE_CFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \ + CXXFLAGS := $$($1_BASE_CXXFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \ + LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$(name)), \ +- DISABLED_WARNINGS_gcc := format undef unused-function unused-value, \ ++ DISABLED_WARNINGS_gcc := undef unused-function unused-value, \ + DISABLED_WARNINGS_clang := undef format-nonliteral \ + missing-field-initializers sometimes-uninitialized, \ + LIBS := $$($1_LIBS_$$(name)), \ +--- old/src/hotspot/cpu/aarch64/interpreterRT_aarch64.cpp ++++ new/src/hotspot/cpu/aarch64/interpreterRT_aarch64.cpp +@@ -267,7 +267,7 @@ + + virtual void pass_object() { + intptr_t* addr = single_slot_addr(); +- intptr_t value = *addr == 0 ? NULL : (intptr_t)addr; ++ intptr_t value = *addr == 0 ? (intptr_t) 0 : (intptr_t)addr; + if (pass_gpr(value) < 0) { + pass_stack<>(value); + } +--- old/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp ++++ new/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp +@@ -48,6 +48,10 @@ + #include "utilities/macros.hpp" + #include "utilities/powerOfTwo.hpp" + ++#if ! (defined(__GLIBC__) || defined(__UCLIBC__)) ++#include ++#endif ++ + #ifdef PRODUCT + #define BLOCK_COMMENT(str) // nothing + #else +@@ -1305,7 +1309,11 @@ + // the safepoing polling page. + ucontext_t* uc = (ucontext_t*) ucontext; + // Set polling address. ++#if defined(__GLIBC__) || defined(__UCLIBC__) + address addr = (address)uc->uc_mcontext.regs->gpr[ra] + (ssize_t)ds; ++#else // Musl ++ address addr = (address)uc->uc_mcontext.gp_regs[ra] + (ssize_t) ds; ++#endif + if (polling_address_ptr != NULL) { + *polling_address_ptr = addr; + } +@@ -1368,11 +1376,20 @@ + || (is_stdu(instruction) && rs == 1)) { + int ds = inv_ds_field(instruction); + // return banged address ++#if defined(__GLIBC__) || defined(__UCLIBC__) + return ds+(address)uc->uc_mcontext.regs->gpr[ra]; ++#else // Musl ++ return ds+(address)uc->uc_mcontext.gp_regs[ra]; ++#endif + } else if (is_stdux(instruction) && rs == 1) { + int rb = inv_rb_field(instruction); ++#if defined(__GLIBC__) || defined(__UCLIBC__) + address sp = (address)uc->uc_mcontext.regs->gpr[1]; + long rb_val = (long)uc->uc_mcontext.regs->gpr[rb]; ++#else // Musl ++ 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 + } +--- old/src/hotspot/cpu/ppc/vm_version_ppc.cpp ++++ new/src/hotspot/cpu/ppc/vm_version_ppc.cpp +@@ -52,6 +52,10 @@ + #endif + #endif + ++#if ! (defined(__GLIBC__) || defined(__UCLIBC__)) ++#include ++#endif ++ + bool VM_Version::_is_determine_features_test_running = false; + uint64_t VM_Version::_dscr_val = 0; + +@@ -709,7 +713,7 @@ + unsigned long auxv = getauxval(AT_HWCAP2); + + if (auxv & PPC_FEATURE2_HTM_NOSC) { +- if (auxv & PPC_FEATURE2_HAS_HTM) { ++ if (auxv & PPC_FEATURE2_HTM) { + // TM on POWER8 and POWER9 in compat mode (VM) is supported by the JVM. + // TM on POWER9 DD2.1 NV (baremetal) is not supported by the JVM (TM on + // POWER9 DD2.1 NV has a few issues that need a couple of firmware +--- old/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp ++++ new/src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp +@@ -76,6 +76,10 @@ + # include + # include + ++#if ! (defined(__GLIBC__) || defined(__UCLIBC__)) ++#include ++#endif ++ + + address os::current_stack_pointer() { + return (address)__builtin_frame_address(0); +@@ -103,24 +107,42 @@ + // - if uc was filled by getcontext(), it is undefined - getcontext() does not fill + // it because the volatile registers are not needed to make setcontext() work. + // Hopefully it was zero'd out beforehand. ++#if defined(__GLIBC__) || defined(__UCLIBC__) + guarantee(uc->uc_mcontext.regs != NULL, "only use ucontext_get_pc in sigaction context"); + return (address)uc->uc_mcontext.regs->nip; ++#else // Musl ++ guarantee(uc->uc_mcontext.gp_regs != NULL, "only use ucontext_get_pc in sigaction context"); ++ return (address)uc->uc_mcontext.gp_regs[PT_NIP]; ++#endif + } + + // modify PC in ucontext. + // Note: Only use this for an ucontext handed down to a signal handler. See comment + // in ucontext_get_pc. + void os::Posix::ucontext_set_pc(ucontext_t * uc, address pc) { ++#if defined(__GLIBC__) || defined(__UCLIBC__) + guarantee(uc->uc_mcontext.regs != NULL, "only use ucontext_set_pc in sigaction context"); + uc->uc_mcontext.regs->nip = (unsigned long)pc; ++#else // Musl ++ guarantee(uc->uc_mcontext.gp_regs != NULL, "only use ucontext_set_pc in sigaction context"); ++ uc->uc_mcontext.gp_regs[PT_NIP] = (unsigned long)pc; ++#endif + } + + static address ucontext_get_lr(const ucontext_t * uc) { ++#if defined(__GLIBC__) || defined(__UCLIBC__) + return (address)uc->uc_mcontext.regs->link; ++#else // Musl ++ return (address)uc->uc_mcontext.gp_regs[PT_LNK]; ++#endif + } + + intptr_t* os::Linux::ucontext_get_sp(const ucontext_t * uc) { ++#if defined(__GLIBC__) || defined(__UCLIBC__) + return (intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/]; ++#else // Musl ++ return (intptr_t*)uc->uc_mcontext.gp_regs[1/*REG_SP*/]; ++#endif + } + + intptr_t* os::Linux::ucontext_get_fp(const ucontext_t * uc) { +@@ -128,7 +150,11 @@ + } + + static unsigned long ucontext_get_trap(const ucontext_t * uc) { ++#if defined(__GLIBC__) || defined(__UCLIBC__) + return uc->uc_mcontext.regs->trap; ++#else // Musl ++ return uc->uc_mcontext.gp_regs[PT_TRAP]; ++#endif + } + + address os::fetch_frame_from_context(const void* ucVoid, +@@ -194,7 +220,11 @@ + // 3.2.1 "Machine State Register"), however note that ISA notation for bit + // numbering is MSB 0, so for normal bit numbering (LSB 0) they come to be + // bits 33 and 34. It's not related to endianness, just a notation matter. ++#if defined(__GLIBC__) || defined(__UCLIBC__) + if (second_uc->uc_mcontext.regs->msr & 0x600000000) { ++#else // Musl ++ if (second_uc->uc_mcontext.gp_regs[PT_MSR] & 0x600000000) { ++#endif + if (TraceTraps) { + tty->print_cr("caught signal in transaction, " + "ignoring to jump to abort handler"); +@@ -450,6 +480,7 @@ + const ucontext_t* uc = (const ucontext_t*)context; + + st->print_cr("Registers:"); ++#if defined(__GLIBC__) || defined(__UCLIBC__) + 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); +@@ -458,6 +489,16 @@ + 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(); + } +@@ -487,12 +528,22 @@ + st->print_cr("Register to memory mapping:"); + st->cr(); + ++#if defined(__GLIBC__) || defined(__UCLIBC__) + st->print("pc ="); print_location(st, (intptr_t)uc->uc_mcontext.regs->nip); + st->print("lr ="); print_location(st, (intptr_t)uc->uc_mcontext.regs->link); + st->print("ctr ="); print_location(st, (intptr_t)uc->uc_mcontext.regs->ctr); ++#else // Musl ++ st->print("pc ="); print_location(st, (intptr_t)uc->uc_mcontext.gp_regs[PT_NIP]); ++ st->print("lr ="); print_location(st, (intptr_t)uc->uc_mcontext.gp_regs[PT_LNK]); ++ st->print("ctr ="); print_location(st, (intptr_t)uc->uc_mcontext.gp_regs[PT_CTR]); ++#endif + for (int i = 0; i < 32; i++) { + st->print("r%-2d=", i); ++#if defined(__GLIBC__) || defined(__UCLIBC__) + print_location(st, uc->uc_mcontext.regs->gpr[i]); ++#else // Musl ++ print_location(st, uc->uc_mcontext.gp_regs[i]); ++#endif + } + st->cr(); + } +--- old/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp ++++ new/src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp +@@ -28,6 +28,10 @@ + #include "runtime/frame.inline.hpp" + #include "runtime/thread.hpp" + ++#if ! (defined(__GLIBC__) || defined(__UCLIBC__)) ++#include ++#endif ++ + frame JavaThread::pd_last_frame() { + assert(has_last_Java_frame(), "must have last_Java_sp() when suspended"); + +@@ -65,14 +69,23 @@ + // if we were running Java code when SIGPROF came in. + if (isInJava) { + ucontext_t* uc = (ucontext_t*) ucontext; +- address pc = (address)uc->uc_mcontext.regs->nip; ++ #if defined(__GLIBC__) || defined(__UCLIBC__) ++ address pc = (address)uc->uc_mcontext.regs->nip; ++ #else // Musl ++ address pc = (address)uc->uc_mcontext.gp_regs[PT_NIP]; ++ #endif ++ + + if (pc == NULL) { + // ucontext wasn't useful + return false; + } + +- frame ret_frame((intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/], pc); ++ #if defined(__GLIBC__) || defined(__UCLIBC__) ++ frame ret_frame((intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/], pc); ++ #else // Musl ++ frame ret_frame((intptr_t*)uc->uc_mcontext.gp_regs[1/*REG_SP*/], pc); ++ #endif + + if (ret_frame.fp() == NULL) { + // The found frame does not have a valid frame pointer. +@@ -91,7 +104,11 @@ + if (!Method::is_valid_method(m)) return false; + if (!Metaspace::contains(m->constMethod())) return false; + ++#if defined(__GLIBC__) || defined(__UCLIBC__) + uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/]; ++#else // Musl ++ 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());