community/openjdk8-corretto: new aport

https://github.com/corretto/corretto-8
Amazon's no-cost, multi-platform, production-ready distribution of OpenJDK 8

This aport can be cross-compiled with the same method used
for openjdk11/17/21, unlike community/openjdk8 (icedtea).
This commit is contained in:
Celeste 2024-09-08 08:29:24 +00:00
parent daf3aa4b67
commit abc39eddbf
10 changed files with 916 additions and 0 deletions

View File

@ -0,0 +1,308 @@
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=openjdk8-corretto
pkgver=8.422.05.1
pkgrel=0
_majorver=${pkgver%%.*}
pkgdesc="Corretto OpenJDK $_majorver"
provider_priority=$((_majorver - 1)) # prefer community/openjdk8 over this aport
url="https://github.com/corretto/corretto-$_majorver"
# armhf, armv7: arch misdetected
# riscv64: no upstream support
# s390x: unrecognized opcodes
# x86: check() encounters fatal error
arch="aarch64 loongarch64 ppc64le x86_64"
# https://aws.amazon.com/corretto/faqs/#Licensing_and_Open_Source
license="GPL-2.0-only WITH Classpath-exception-2.0"
options="sover-namecheck"
makedepends_build="
openjdk$_majorver-bootstrap
autoconf
bash
gawk
grep
make
zip
"
makedepends_host="
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
"
subpackages="
$pkgname-demos
$pkgname-doc
$pkgname-jre
$pkgname-jre-lib:jrelib:noarch
$pkgname-jre-base:jrebase
$pkgname-jdk
"
source="jdk-corretto-$pkgver.tar.gz::https://github.com/corretto/corretto-$_majorver/archive/refs/tags/$pkgver.tar.gz
icedtea-JDK-6515172.patch
icedtea-hotspot-lfs64.patch
icedtea-hotspot-musl.patch
icedtea-hotspot-musl-ppc.patch
icedtea-jdk-disable-vfork.patch
icedtea-jdk-fix-ipv6-init.patch
icedtea-jdk-fix-libjvm-load.patch
icedtea-jdk-implicit.patch
Example.java
"
builddir="$srcdir/corretto-$_majorver-$pkgver"
provides="openjdk$_majorver-bootstrap"
replaces="openjdk$_majorver"
case $CARCH in
x86) _jarch=i386;;
x86_64) _jarch=amd64;;
arm*) _jarch=aarch32;;
*) _jarch="$CARCH";;
esac
_java_home="/usr/lib/jvm/java-1.8-openjdk"
_jrelib="$_java_home/jre/lib/$_jarch"
# Exclude xawt from ldpath to avoid duplicate provides for libmawt.so
# (also in headless). in future this should be a virtual provides.
ldpath="$_jrelib:$_jrelib/native_threads:$_jrelib/headless:$_jrelib/server:$_jrelib/jli"
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
_jvm_variants=server
case $CTARGET_ARCH in
loongarch64) _jvm_variants=zero ;;
esac
prepare() {
default_prepare
# update autoconf files to detect alpine
update_config_guess
update_config_sub
}
_configure() {
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
if [ -z "$JOBS" ]; then
export JOBS=$(printf '%s\n' "$MAKEFLAGS" | sed -n -e 's/.*-j\([0-9]\+\).*/\1/p')
fi
# 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 \
--openjdk-target=$CHOST \
--prefix="$_java_home" \
--sysconfdir=/etc \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--localstatedir=/var \
--with-zlib=bundled \
--with-giflib=system \
--with-jobs=${JOBS:-4} \
--with-native-debug-symbols=none \
$ccache \
$_with_jtreg \
--with-milestone="fcs" \
--with-jvm-variants=$_jvm_variants \
--with-debug-level=release \
--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" \
"$@"
}
build() {
_extra_cflags="-DMUSL_LIBC \
-Wno-error=stringop-overflow \
-Wno-error=nonnull \
"
# we want to build hotspot with better optimisations; it's set to this
# (prepended) anyway, and it's huge
export CFLAGS="$CFLAGS -O3 $_extra_cflags"
export CXXFLAGS="$CXXFLAGS -O3 $_extra_cflags"
export CPPFLAGS="$CPPFLAGS $_extra_cflags"
if [ "$CBUILD" = "$CTARGET" ]; then
_configure \
--with-extra-cflags="$CFLAGS" \
--with-extra-cxxflags="$CXXFLAGS" \
--with-extra-ldflags="$LDFLAGS"
else
_configure \
--with-sysroot="$HOME/sysroot-$CTARGET_ARCH" \
--with-cups="$HOME/sysroot-$CTARGET_ARCH/usr" \
--with-freetype-lib="$HOME/sysroot-$CTARGET_ARCH/usr/lib" \
--with-freetype-include="$HOME/sysroot-$CTARGET_ARCH/usr/include/freetype2" \
--with-alsa="$HOME/sysroot-$CTARGET_ARCH/usr" \
--with-fontconfig="$HOME/sysroot-$CTARGET_ARCH/usr" \
--with-extra-cflags="$CFLAGS" \
--with-extra-cxxflags="$CXXFLAGS" \
--with-extra-ldflags="-Wl,--as-needed,-O1,--sort-common"
fi
MAKEFLAGS='' make JOBS="${JOBS:-4}" images
}
# TODO: Run JTReg tests if enabled through $_run_jtreg.
check() {
cd build/linux-*-$_jvm_variants-release/images/j2sdk-image
./bin/java -version
./bin/javac "$srcdir"/Example.java -d "$builddir"
./bin/java -classpath "$builddir" Example
}
package() {
depends="$pkgname-jdk=$pkgver-r$pkgrel"
mkdir -p "$pkgdir"/$_java_home
cd build/linux-*-$_jvm_variants-release/images/
cp -a j2sdk-image/* "$pkgdir"/$_java_home/
rm -v "$pkgdir"/$_java_home/src.zip
# symlink to shared java cacerts store
rm -v "$pkgdir"/$_java_home/jre/lib/security/cacerts
ln -sv /etc/ssl/certs/java/cacerts \
"$pkgdir"/$_java_home/jre/lib/security/cacerts
}
jrelib() {
pkgdesc="$pkgdesc Java Runtime (class libraries)"
depends="java-cacerts"
provides="openjdk$_majorver-jre-lib"
replaces="openjdk$_majorver-jre-lib"
amove \
$_java_home/jre/lib/images \
$_java_home/jre/lib/\*.jar \
$_java_home/jre/lib/security \
$_java_home/jre/lib/ext/\*.jar \
$_java_home/jre/lib/cmm \
$_java_home/jre/ASSEMBLY_EXCEPTION \
$_java_home/jre/THIRD_PARTY_README \
$_java_home/jre/LICENSE
}
jre() {
pkgdesc="$pkgdesc Java Runtime"
depends="font-dejavu"
provides="java-jre openjdk$_majorver-jre"
replaces="openjdk$_majorver-jre"
amove \
$_java_home/jre/bin/policytool \
$_java_home/bin/appletviewer \
$_java_home/bin/policytool \
$_java_home/jre/lib/$_jarch/libawt_xawt.so \
$_java_home/jre/lib/$_jarch/libfontmanager.so \
$_java_home/jre/lib/$_jarch/libjawt.so \
$_java_home/jre/lib/$_jarch/libjsoundalsa.so \
$_java_home/jre/lib/$_jarch/libsplashscreen.so
}
jrebase() {
pkgdesc="$pkgdesc Java Runtime (no GUI support)"
depends="$pkgname-jre-lib=$pkgver-r$pkgrel java-common"
provides="java-jre-headless openjdk$_majorver-jre-base"
replaces="openjdk$_majorver-jre-base"
amove \
$_java_home/bin/java \
$_java_home/bin/orbd \
$_java_home/bin/rmid \
$_java_home/bin/servertool \
$_java_home/bin/unpack200 \
$_java_home/bin/keytool \
$_java_home/bin/pack200 \
$_java_home/bin/rmiregistry \
$_java_home/bin/tnameserv \
$_java_home/lib/$_jarch/jli
# Rest of the jre subdir (which were not taken by -jre subpkg).
amove $_java_home/jre
ln -s java-1.8-openjdk "$subpkgdir"/usr/lib/jvm/java-8-openjdk
}
doc() {
default_doc
amove $_java_home/man
}
demos() {
pkgdesc="$pkgdesc Java Demos and Samples"
depends="$pkgname-jdk=$pkgver-r$pkgrel"
provides="openjdk$_majorver-demos"
replaces="openjdk$_majorver-demos"
amove \
$_java_home/demo \
$_java_home/sample
}
jdk() {
pkgdesc="$pkgdesc (JDK) ($_jvm_variants variant)"
depends="$pkgname-jre=$pkgver-r$pkgrel"
provides="java-jdk openjdk$_majorver-jdk"
replaces="openjdk$_majorver-jdk"
amove \
$_java_home/bin \
$_java_home/lib \
$_java_home/include
}
sha512sums="
6913142ab1f93df23aa55c1a03610d8c7f355e8a61adeff05c1fd439ace852e45ee0ad513ecba90ad87522b8c51b73fcbcccfca1cc8a1258d0210eab9c86cfc0 jdk-corretto-8.422.05.1.tar.gz
c9808b42e60749eb482762f046230e89fd07d51c95a31b59540628f74ddc49680cfdcc9b45d92b5770076977c54841277e12077863ed27d47c54d70af03750aa icedtea-JDK-6515172.patch
6717172162cfc638de0e7a9ef80fd512f215a094d3dd6ca472c735445e612a804c4e97ced32a9618385130c054b6d333670ab2bd644f4f11daf150f93cd077d1 icedtea-hotspot-lfs64.patch
8afa5f9eda03b5052671840693879998287b95fb56519d0f2b256cc5d8101b1406c98b4170bcc18143b0449e95a56b3d807402f77bba3b1e974b9170f9e2cfd1 icedtea-hotspot-musl.patch
e6fff8ab886f42006ad5c210f46e82a3a4c0b654edecc4764a0d20f0e5dc81138c2c5181b034095b93f94b5aa96b7e5068f42bafa283809f6fe9d2c8655d64d7 icedtea-hotspot-musl-ppc.patch
c70fee8f1a10c155494ab9c6e55e979d8a3e23f12358ffe9de2029ae15feff361957f1aa43af43c90ecf00523f92e3333b40311a8d0c132ebd456486cb85ed8a icedtea-jdk-disable-vfork.patch
48533f87fc2cf29d26b259be0df51087d2fe5b252e72d00c6ea2f4add7b0fb113141718c116279c5905e03f64a1118082e719393786811367cf4d472b5d36774 icedtea-jdk-fix-ipv6-init.patch
b135991c76b0db8fa7c363e0903624668e11eda7b54a943035c214aa4d7fc8c3e8110ed200edcec82792f3c9393150a9bd628625ddf7f3e55720ff163fbbb471 icedtea-jdk-fix-libjvm-load.patch
21a16599d7e0aaf2997db59ada5af63e25484949ca965a34536ee44b950a132a6b5ca0b4922a6919d840a84ba0bb8413d87d2b97ea2c65c00e8766cc470c267d icedtea-jdk-implicit.patch
601ac59e59d32cbaf91f7541bd8173b38c68cbec96a7fb74227017afc8e5dc6ce4b8be03e92dd34cf52370e5d52beb780808af57b17c79c53ae8ec64cd34a92d Example.java
"

View File

@ -0,0 +1,16 @@
// Copied from https://www.graalvm.org/22.0/reference-manual/native-image/.
public class Example {
public static void main(String[] args) {
String str = "Native Image is awesome";
String reversed = reverseString(str);
System.out.println("The reversed string is: " + reversed);
}
public static String reverseString(String str) {
if (str.isEmpty())
return str;
return reverseString(str.substring(1)) + str.charAt(0);
}
}

View File

@ -0,0 +1,97 @@
Make aarch64 builds more stable if NUMA-domain-using CPU's do not start from 0.
ref: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/24563
diff --git a/hotspot/src/os/linux/vm/globals_linux.hpp b/hotspot/src/os/linux/vm/globals_linux.hpp
index f98bde41a..23239d9ad 100644
--- a/hotspot/src/os/linux/vm/globals_linux.hpp
+++ b/hotspot/src/os/linux/vm/globals_linux.hpp
@@ -49,6 +49,9 @@
product(bool, UseSHM, false, \
"Use SYSV shared memory for large pages") \
\
+ diagnostic(bool, UseCpuAllocPath, false, \
+ "Use CPU_ALLOC code path in os::active_processor_count ") \
+ \
product(bool, UseContainerSupport, true, \
"Enable detection and runtime container configuration support") \
\
diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp
index 10665b9b2..8e6f99bf3 100644
--- a/hotspot/src/os/linux/vm/os_linux.cpp
+++ b/hotspot/src/os/linux/vm/os_linux.cpp
@@ -5319,41 +5319,56 @@ void os::make_polling_page_readable(void) {
}
};
-static int os_cpu_count(const cpu_set_t* cpus) {
- int count = 0;
- // only look up to the number of configured processors
- for (int i = 0; i < os::processor_count(); i++) {
- if (CPU_ISSET(i, cpus)) {
- count++;
- }
- }
- return count;
-}
-
// Get the current number of available processors for this process.
// This value can change at any time during a process's lifetime.
// sched_getaffinity gives an accurate answer as it accounts for cpusets.
+// If it appears there may be more than 1024 processors then we do a
+// dynamic check - see 6515172 for details.
// If anything goes wrong we fallback to returning the number of online
// processors - which can be greater than the number available to the process.
int os::Linux::active_processor_count() {
cpu_set_t cpus; // can represent at most 1024 (CPU_SETSIZE) processors
+ cpu_set_t* cpus_p = &cpus;
int cpus_size = sizeof(cpu_set_t);
+
+ int configured_cpus = processor_count(); // upper bound on available cpus
int cpu_count = 0;
+ // To enable easy testing of the dynamic path on different platforms we
+ // introduce a diagnostic flag: UseCpuAllocPath
+ if (configured_cpus >= CPU_SETSIZE || UseCpuAllocPath) {
+ // kernel may use a mask bigger than cpu_set_t
+ cpus_p = CPU_ALLOC(configured_cpus);
+ if (cpus_p != NULL) {
+ cpus_size = CPU_ALLOC_SIZE(configured_cpus);
+ // zero it just to be safe
+ CPU_ZERO_S(cpus_size, cpus_p);
+ }
+ else {
+ // failed to allocate so fallback to online cpus
+ int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
+ return online_cpus;
+ }
+ }
+
// pid 0 means the current thread - which we have to assume represents the process
- if (sched_getaffinity(0, cpus_size, &cpus) == 0) {
- cpu_count = os_cpu_count(&cpus);
- if (PrintActiveCpus) {
- tty->print_cr("active_processor_count: sched_getaffinity processor count: %d", cpu_count);
+ if (sched_getaffinity(0, cpus_size, cpus_p) == 0) {
+ if (cpus_p != &cpus) {
+ cpu_count = CPU_COUNT_S(cpus_size, cpus_p);
+ }
+ else {
+ cpu_count = CPU_COUNT(cpus_p);
}
}
else {
cpu_count = ::sysconf(_SC_NPROCESSORS_ONLN);
- warning("sched_getaffinity failed (%s)- using online processor count (%d) "
- "which may exceed available processors", strerror(errno), cpu_count);
}
- assert(cpu_count > 0 && cpu_count <= os::processor_count(), "sanity check");
+ if (cpus_p != &cpus) {
+ CPU_FREE(cpus_p);
+ }
+
+ assert(cpu_count > 0 && cpu_count <= processor_count(), "sanity check");
return cpu_count;
}

View File

@ -0,0 +1,133 @@
--- openjdk/hotspot/src/os/linux/vm/attachListener_linux.cpp
+++ openjdk/hotspot/src/os/linux/vm/attachListener_linux.cpp
@@ -446,14 +446,14 @@
void AttachListener::vm_start() {
char fn[UNIX_PATH_MAX];
- struct stat64 st;
+ struct stat st;
int ret;
int n = snprintf(fn, UNIX_PATH_MAX, "%s/.java_pid%d",
os::get_temp_directory(), os::current_process_id());
assert(n < (int)UNIX_PATH_MAX, "java_pid file name buffer overflow");
- RESTARTABLE(::stat64(fn, &st), ret);
+ RESTARTABLE(::stat(fn, &st), ret);
if (ret == 0) {
ret = ::unlink(fn);
if (ret == -1) {
@@ -480,8 +480,8 @@
bool AttachListener::check_socket_file() {
int ret;
- struct stat64 st;
- ret = stat64(LinuxAttachListener::path(), &st);
+ struct stat st;
+ ret = stat(LinuxAttachListener::path(), &st);
if (ret == -1) { // need to restart attach listener.
debug_only(warning("Socket file %s does not exist - Restart Attach Listener",
LinuxAttachListener::path()));
@@ -521,12 +521,12 @@
char fn[PATH_MAX+1];
sprintf(fn, ".attach_pid%d", os::current_process_id());
int ret;
- struct stat64 st;
- RESTARTABLE(::stat64(fn, &st), ret);
+ struct stat st;
+ RESTARTABLE(::stat(fn, &st), ret);
if (ret == -1) {
snprintf(fn, sizeof(fn), "%s/.attach_pid%d",
os::get_temp_directory(), os::current_process_id());
- RESTARTABLE(::stat64(fn, &st), ret);
+ RESTARTABLE(::stat(fn, &st), ret);
}
if (ret == 0) {
// simple check to avoid starting the attach mechanism when
--- openjdk/hotspot/src/os/linux/vm/os_linux.cpp
+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp
@@ -5613,13 +5613,13 @@
int o_delete = (oflag & O_DELETE);
oflag = oflag & ~O_DELETE;
- fd = ::open64(path, oflag, mode);
+ fd = ::open(path, oflag, mode);
if (fd == -1) return -1;
//If the open succeeded, the file might still be a directory
{
- struct stat64 buf64;
- int ret = ::fstat64(fd, &buf64);
+ struct stat buf64;
+ int ret = ::fstat(fd, &buf64);
int st_mode = buf64.st_mode;
if (ret != -1) {
@@ -5696,17 +5696,17 @@
if (!rewrite_existing) {
oflags |= O_EXCL;
}
- return ::open64(path, oflags, S_IREAD | S_IWRITE);
+ return ::open(path, oflags, S_IREAD | S_IWRITE);
}
// return current position of file pointer
jlong os::current_file_offset(int fd) {
- return (jlong)::lseek64(fd, (off64_t)0, SEEK_CUR);
+ return (jlong)::lseek(fd, (off_t)0, SEEK_CUR);
}
// move file pointer to the specified offset
jlong os::seek_to_file_offset(int fd, jlong offset) {
- return (jlong)::lseek64(fd, (off64_t)offset, SEEK_SET);
+ return (jlong)::lseek(fd, (off_t)offset, SEEK_SET);
}
// This code originates from JDK's sysAvailable
@@ -5715,9 +5715,9 @@
int os::available(int fd, jlong *bytes) {
jlong cur, end;
int mode;
- struct stat64 buf64;
+ struct stat buf64;
- if (::fstat64(fd, &buf64) >= 0) {
+ if (::fstat(fd, &buf64) >= 0) {
mode = buf64.st_mode;
if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) {
/*
@@ -5732,11 +5732,11 @@
}
}
}
- if ((cur = ::lseek64(fd, 0L, SEEK_CUR)) == -1) {
+ if ((cur = ::lseek(fd, 0L, SEEK_CUR)) == -1) {
return 0;
- } else if ((end = ::lseek64(fd, 0L, SEEK_END)) == -1) {
+ } else if ((end = ::lseek(fd, 0L, SEEK_END)) == -1) {
return 0;
- } else if (::lseek64(fd, cur, SEEK_SET) == -1) {
+ } else if (::lseek(fd, cur, SEEK_SET) == -1) {
return 0;
}
*bytes = end - cur;
--- openjdk/hotspot/src/os/linux/vm/os_linux.inline.hpp
+++ openjdk/hotspot/src/os/linux/vm/os_linux.inline.hpp
@@ -88,7 +88,7 @@
inline const int os::default_file_open_flags() { return 0;}
inline jlong os::lseek(int fd, jlong offset, int whence) {
- return (jlong) ::lseek64(fd, offset, whence);
+ return (jlong) ::lseek(fd, offset, whence);
}
inline int os::fsync(int fd) {
@@ -100,7 +100,7 @@
}
inline int os::ftruncate(int fd, jlong length) {
- return ::ftruncate64(fd, length);
+ return ::ftruncate(fd, length);
}
// macros for restartable system calls

View File

@ -0,0 +1,226 @@
Subject: Fix compilation with different ucontext_t on musl
Upstream: No
Author: Simon Frankenberger <simon-alpine@fraho.eu>
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.
--- openjdk/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp
+++ openjdk/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.
+#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;
}
@@ -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
+#if defined(__GLIBC__) || defined(__UCLIBC__)
address ra_val=(address)uc->uc_mcontext.regs->gpr[ra];
long rb_val=(long)uc->uc_mcontext.regs->gpr[rb];
+#else // Musl
+ 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
+#if defined(__GLIBC__) || defined(__UCLIBC__)
address ra_val=(address)uc->uc_mcontext.regs->gpr[ra];
+#else // Musl
+ 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
+#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
}
--- openjdk/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp
+++ openjdk/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp
@@ -75,6 +75,10 @@
# include <poll.h>
# include <ucontext.h>
+#if ! (defined(__GLIBC__) || defined(__UCLIBC__))
+# include <asm/ptrace.h>
+#endif
+
address os::current_stack_pointer() {
intptr_t* csp;
@@ -110,11 +114,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");
+#if defined(__GLIBC__) || defined(__UCLIBC__)
return (address)uc->uc_mcontext.regs->nip;
+#else // Musl
+ return (address)uc->uc_mcontext.gp_regs[PT_NIP];
+#endif
}
intptr_t* os::Linux::ucontext_get_sp(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(ucontext_t * uc) {
@@ -213,7 +225,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)) {
+#if defined(__GLIBC__) || defined(__UCLIBC__)
uc->uc_mcontext.regs->nip = (unsigned long)StubRoutines::continuation_for_safefetch_fault(pc);
+#else // Musl
+ uc->uc_mcontext.gp_regs[PT_NIP] = (unsigned long)StubRoutines::continuation_for_safefetch_fault(pc);
+#endif
return true;
}
}
@@ -364,7 +380,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();
+#if defined(__GLIBC__) || defined(__UCLIBC__)
uc->uc_mcontext.regs->nip = ((unsigned long)pc) + 4;
+#else // Musl
+ uc->uc_mcontext.gp_regs[PT_NIP] = ((unsigned long)pc) + 4;
+#endif
return true;
}
}
@@ -383,7 +403,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();
+#if defined(__GLIBC__) || defined(__UCLIBC__)
uc->uc_mcontext.regs->nip = ((unsigned long)pc) + 4;
+#else // Musl
+ uc->uc_mcontext.gp_regs[PT_NIP] = ((unsigned long)pc) + 4;
+#endif
return true;
}
}
@@ -406,7 +430,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);
+#if defined(__GLIBC__) || defined(__UCLIBC__)
uc->uc_mcontext.regs->nip = (unsigned long)stub;
+#else
+ uc->uc_mcontext.gp_regs[PT_NIP] = (unsigned long)stub;
+#endif
return true;
}
@@ -564,6 +592,7 @@ void os::print_context(outputStream *st, void *context) {
ucontext_t* uc = (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);
@@ -572,6 +601,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();
@@ -600,7 +639,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);
+#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();
}
--- openjdk/hotspot/src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp
+++ openjdk/hotspot/src/os_cpu/linux_ppc/vm/thread_linux_ppc.cpp
@@ -27,6 +27,10 @@
#include "runtime/frame.inline.hpp"
#include "runtime/thread.hpp"
+#if ! (defined(__GLIBC__) || defined(__UCLIBC__))
+#include <asm/ptrace.h>
+#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;
+#if defined(__GLIBC__) || defined(__UCLIBC__)
frame ret_frame((intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/],
(address)uc->uc_mcontext.regs->nip);
+#else // Musl
+ 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;
+#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());

View File

@ -0,0 +1,38 @@
diff --git openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
index 38388cb..2505ba8 100644
--- openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
+++ openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
@@ -72,9 +72,6 @@
# include <pwd.h>
# include <poll.h>
# include <ucontext.h>
-#ifndef AMD64
-# include <fpu_control.h>
-#endif
#ifdef AMD64
#define REG_SP REG_RSP
@@ -544,6 +543,9 @@ JVM_handle_linux_signal(int sig,
return true; // Mute compiler
}
+#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
+#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
+
void os::Linux::init_thread_fpu_state(void) {
#ifndef AMD64
// set fpu to 53 bit precision
diff --git openjdk/hotspot/src/os_cpu/linux_x86/vm/threadLS_linux_x86.hpp openjdk/hotspot/src/os_cpu/linux_x86/vm/threadLS_linux_x86.hpp
index f3f2f26..6b50cfa 100644
--- openjdk/hotspot/src/os_cpu/linux_x86/vm/threadLS_linux_x86.hpp
+++ openjdk/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
+ #ifndef PAGE_SIZE
#define PAGE_SIZE (1UL << PAGE_SHIFT)
+ #endif
static Thread* _sp_map[1UL << (SP_BITLENGTH - PAGE_SHIFT)];
public:

View File

@ -0,0 +1,27 @@
--- openjdk.orig/jdk/src/solaris/native/java/lang/UNIXProcess_md.c
+++ openjdk/jdk/src/solaris/native/java/lang/UNIXProcess_md.c
@@ -552,7 +552,11 @@
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
+#if defined(__GLIBC__) || defined(__UCLIBC__)
return vforkChild(c);
+#endif
case MODE_FORK:
return forkChild(c);
#if defined(__solaris__) || defined(_ALLBSD_SOURCE) || defined(_AIX)
@@ -651,8 +655,12 @@
if (resultPid < 0) {
switch (c->mode) {
case MODE_VFORK:
+// use regular fork when running on musl
+// this should fix deadlocks on aarch64
+#if defined(__GLIBC__) || defined(__UCLIBC__)
throwIOException(env, errno, "vfork failed");
break;
+#endif
case MODE_FORK:
throwIOException(env, errno, "fork failed");
break;

View File

@ -0,0 +1,42 @@
--- openjdk/jdk/src/solaris/native/java/net/net_util_md.c.orig
+++ openjdk/jdk/src/solaris/native/java/net/net_util_md.c
@@ -561,7 +561,7 @@
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 */
@@ -573,6 +573,10 @@
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 ;
}
@@ -601,7 +605,7 @@
localifs = (struct localinterface *) realloc (
localifs, sizeof (struct localinterface)* (localifsSize+5));
if (localifs == 0) {
- nifs = 0;
+ nifs = -1;
fclose (f);
return;
}
@@ -624,9 +628,7 @@
static int getLocalScopeID (char *addr) {
struct localinterface *lif;
int i;
- if (localifs == 0) {
- initLocalIfs();
- }
+ initLocalIfs();
for (i=0, lif=localifs; i<nifs; i++, lif++) {
if (memcmp (addr, lif->localaddr, 16) == 0) {
return lif->index;

View File

@ -0,0 +1,14 @@
musl needs LD_LIBRARY_PATH set because when .so is opened with dlopen(/abs/path)
it does not qualify for providing symbols for NEEDED dependency.
--- openjdk.orig/jdk/src/solaris/bin/java_md_solinux.c
+++ openjdk/jdk/src/solaris/bin/java_md_solinux.c
@@ -291,6 +291,8 @@
char *dmllp = NULL;
char *p; /* a utility pointer */
+ return JNI_TRUE;
+
#ifdef AIX
/* We always have to set the LIBPATH on AIX because ld doesn't support $ORIGIN. */
return JNI_TRUE;

View File

@ -0,0 +1,15 @@
musl doesn't have isnanf, and this fixes an implicit-function-decl
how did this even compile without failing at link time?
rest for implicit
--
--- openjdk/jdk/src/solaris/native/common/jdk_util_md.h
+++ openjdk/jdk/src/solaris/native/common/jdk_util_md.h
@@ -37,7 +37,7 @@
#define ISNAND(d) isnan(d)
#elif defined(__linux__) || defined(_ALLBSD_SOURCE)
#include <math.h>
-#define ISNANF(f) isnanf(f)
+#define ISNANF(f) isnan(f)
#define ISNAND(d) isnan(d)
#elif defined(_AIX)
#include <math.h>